public void SmsController_IfRecordExists_ShouldReturnMessage() { // Arrange var repository = new MockSmsRepository(); var guid = Guid.NewGuid(); var to = Guid.NewGuid().ToString(); var model = new SmsMessage { Created = DateTime.UtcNow, From = Guid.NewGuid().ToString(), Guid = guid, Message = Guid.NewGuid().ToString(), To = to }; repository.Insert(model); var controller = new SmsController(repository); // Act var result1 = controller.Get(guid); var result2 = controller.Get(to, guid); // Assert Assert.IsTrue(result1 is OkNegotiatedContentResult <SmsMessage>); Assert.IsTrue(result2 is OkNegotiatedContentResult <SmsMessage>); var content1 = (result1 as OkNegotiatedContentResult <SmsMessage>).Content; var content2 = (result2 as OkNegotiatedContentResult <SmsMessage>).Content; Assert.IsTrue(content1.Guid == guid); Assert.IsTrue(content2.Guid == guid); }
public void SmsController_IfRecordDoesNotExists_ShouldReturnNotFound() { // Arrange var repository = new MockSmsRepository(); var model = new SmsMessage { Created = DateTime.UtcNow, From = Guid.NewGuid().ToString(), Guid = Guid.NewGuid(), Message = Guid.NewGuid().ToString(), To = Guid.NewGuid().ToString() }; repository.Insert(model); var controller = new SmsController(repository); // Act var result1 = controller.Get(Guid.NewGuid()); var result2 = controller.Get(Guid.NewGuid().ToString(), Guid.NewGuid()); // Assert Assert.IsTrue(result1 is NotFoundResult); Assert.IsTrue(result2 is NotFoundResult); }