jeudi 30 juillet 2015

Unit tests and testing the test

My app has the ability to update an item. I would like to create a unit test for this.

This is in c# using Moq. When I call the setup method in mock. I am having it take an existing item, and then update it as needed.

      messageMock.Setup(m => m.SaveMessage(It.IsAny<Message>())).Callback((Message msg) =>
        {
            var oldMsg = _messages.FirstOrDefault(m => m.Id == msg.MessageID);
            if (oldMsg != null)
            {
                oldMsg.Description = msg.Description;
                oldMsg.IsActive = msg.IsActive;
                oldMsg.Name = msg.Name;
                oldMsg.Type = msg.Type;
            }
        }).Verifiable();

If the logic of updating the item is done in Moq, then I am just testing the test. How can I test the business logic of update functionality?

Aucun commentaire:

Enregistrer un commentaire