public void Test_Update_IfYearIsNotValid() { m_MockSeriePropertyPresenter.Serie = new Serie{ Id = 0, Name = "name", Description = "desc", PublicationYear = new DateTime(1700, 1, 1), Category = new Category { Id = 1 }}; SeriePropertyPresenter seriePropertyService = new SeriePropertyPresenter(m_MockSeriePropertyPresenter); seriePropertyService.SetFields(); Assert.IsFalse(seriePropertyService.Update()); Assert.IsTrue(m_MockSeriePropertyPresenter.ErrorMessage.Visible); string expected = "Bitte geben Sie ein gültiges Jahr ein!" + Environment.NewLine; Assert.AreEqual(expected, m_MockSeriePropertyPresenter.ErrorMessage.Text); }
public void Test_SetFields_CateogryIsNotNull() { SeriePropertyPresenter seriePropertyService = new SeriePropertyPresenter(m_MockSeriePropertyPresenter); m_MockSeriePropertyPresenter.Serie = new Serie{ Id = 0, Name = "Test", Description = "Desc", PublicationYear = new DateTime(2000, 1, 1), Category = new Category {Id = 1}}; seriePropertyService.SetFields(); Assert.AreEqual("Test", m_MockSeriePropertyPresenter.Name.Text); Assert.AreEqual("Desc", m_MockSeriePropertyPresenter.Description.Text); Assert.AreEqual("2000", m_MockSeriePropertyPresenter.PublicationYear.Text); ICategoryService categoryService = ObjectFactory.GetInstance<ICategoryService>(); var category = categoryService.GetById(1); Assert.AreEqual(category.Id.ToString(), m_MockSeriePropertyPresenter.ChooseCategory.SelectedItem.Value); Assert.AreEqual(category.Name, m_MockSeriePropertyPresenter.ChooseCategory.SelectedItem.Text); }
public void Test_Update_IfNameAndYearAreValid() { m_MockSeriePropertyPresenter.Serie = new Serie{ Id = 0, Name = "test serie update", Description = "desc serie update", PublicationYear = new DateTime(1981, 1, 1), Category = new Category { Id = 1 }}; SeriePropertyPresenter seriePropertyService = new SeriePropertyPresenter(m_MockSeriePropertyPresenter); seriePropertyService.SetFields(); Assert.IsTrue(seriePropertyService.Update()); Assert.IsFalse(m_MockSeriePropertyPresenter.ErrorMessage.Visible); Assert.AreEqual(string.Empty, m_MockSeriePropertyPresenter.ErrorMessage.Text); //Revert saving ISerieService serieService = ObjectFactory.GetInstance<ISerieService>(); var series = serieService.GetAll(); serieService.DeleteById(series[series.Count - 1].Id); }
public void Test_SetFields_CategoryIsNull() { SeriePropertyPresenter seriePropertyService = new SeriePropertyPresenter(m_MockSeriePropertyPresenter); m_MockSeriePropertyPresenter.Serie = null; seriePropertyService.SetFields(); Assert.AreEqual(string.Empty, m_MockSeriePropertyPresenter.Name.Text); Assert.AreEqual(string.Empty, m_MockSeriePropertyPresenter.Description.Text); Assert.AreEqual(string.Empty, m_MockSeriePropertyPresenter.PublicationYear.Text); ICategoryService categoryService = ObjectFactory.GetInstance<ICategoryService>(); var category = categoryService.GetById(1); Assert.AreEqual(category.Id.ToString(), m_MockSeriePropertyPresenter.ChooseCategory.SelectedItem.Value); Assert.AreEqual(category.Name, m_MockSeriePropertyPresenter.ChooseCategory.SelectedItem.Text); }