public void DateNotInPast_WhenDateFieldNotExist_SouldThrowException() { ////Arrange var testEntity = new Event { Id = 1, Date = DateTime.Now.Date.AddDays(1).AddHours(15), Description = "EventDescription1", LayoutId = 1, Name = "EventName1", }; var saverMock = new Mock <ISave <Event> >(); saverMock.Setup(s => s.Save(testEntity)).Returns(testEntity); var testSaver = new DateNotInPastSaver <Event>(saverMock.Object, "BadField"); ////Act void TestAction() { testSaver.Save(testEntity); } ////Assert Assert.Throws <MissingFieldException>(TestAction); }
public void DateNotInPast_FieldExistButNotDateType_NegativeTest() { ////Arrange var testEntity = new Event { Id = 1, Date = DateTime.Now.Date.AddDays(1).AddHours(15), Description = "EventDescription1", LayoutId = 1, Name = "EventName1", }; var saverMock = new Mock <ISave <Event> >(); saverMock.Setup(s => s.Save(testEntity)).Returns(testEntity); var testSaver = new DateNotInPastSaver <Event>(saverMock.Object, "Name"); ////Act void TestAction() { testSaver.Save(testEntity); } ////Assert Assert.Throws <InvalidCastException>(TestAction); }
public void DateNotInPast_PositiveTest() { ////Arrange var testEntity = new Event { Id = 1, Date = DateTime.Now.Date.AddDays(1).AddHours(15), Description = "EventDescription1", LayoutId = 1, Name = "EventName1", }; var saverMock = new Mock <ISave <Event> >(); saverMock.Setup(s => s.Save(testEntity)).Returns(testEntity); var testSaver = new DateNotInPastSaver <Event>(saverMock.Object, "Date"); ////Act var testResult = testSaver.Save(testEntity); ////Assert testEntity.Should().BeEquivalentTo(testResult); }