public void PublishedFormServiceGetAllShouldRetrieveActiveForms() { // Arrange var expectedCount = 1; var unitOfWorkMock = new Mock<IUnitOfWork>(MockBehavior.Strict); var publishedForm = new PublishedForm { Title = "Test", IsActive = true, FromDate = DateTime.Now, ExpirationDate = DateTime.Now.AddDays(1), Form = new FormMother().GetBasicSurvey() }; unitOfWorkMock.Setup(u => u.Query<PublishedForm>(It.IsAny<string>())).Returns(new[] { publishedForm }.AsQueryable()); var service = new PublishedFormService(unitOfWorkMock.Object); // Act var actual = service.GetAllActive(); // Assert Assert.IsNotNull(actual); Assert.AreEqual(expectedCount, actual.Count()); Assert.AreSame(publishedForm, actual.FirstOrDefault()); }
public void PublishedFormDefaultConstructorShouldWork() { // Arrage var currentTime = DateTime.Now; var expectedId = Guid.Empty; // Act var actual = new PublishedForm(); // Assert Assert.IsNotNull(actual); Assert.IsNotNull(actual.FromDate); Assert.IsTrue(DateTime.Compare(currentTime, actual.FromDate) >= 0); Assert.IsNull(actual.ExpirationDate); Assert.IsNull(actual.Form); Assert.AreEqual(expectedId, actual.Id); }