public void It__Should_Shorten_Long_Body_Strings_To_40_Characters()
        {
            string body = "01234567890123456789012345678901234567890123456789";
            var viewModel = new AnnouncementViewModel(body, "Title", DateTime.Now.AddDays(1));
            string expected = "0123456789012345678901234567890123456...";

            Assert.AreEqual(expected, viewModel.ShortendBody);
        }
        public void It_Should_Not_Shorten_Short_Body_Strings()
        {
            string body = "0123456789";
            var viewModel = new AnnouncementViewModel(body, "Title", DateTime.Now.AddDays(1));
            string expected = "0123456789";

            Assert.AreEqual(expected, viewModel.ShortendBody);
        }
        public void It_Should_Save_Data_To_The_Model()
        {
            // Arrange
            var fakeView = new FakeAnnouncementView();
            var fakeService = new FakeAnnouncementService();
            var presenter = new AnnouncementPresenter(fakeView, fakeService);

            var viewModel = new AnnouncementViewModel("Body", "Title", DateTime.Now);

            // Act
            presenter.SaveAnnouncement(viewModel);

            // Assert
            Assert.AreEqual(viewModel.Title, fakeService.SavedDto.Title);
            Assert.AreEqual(viewModel.Body, fakeService.SavedDto.Body);
            Assert.AreEqual(viewModel.Expires, fakeService.SavedDto.Expires);
        }
        public void It_Should_Not_Expire_FutureExpireDates()
        {
            var viewModel = new AnnouncementViewModel("Body", "Title", DateTime.Now.AddDays(1));

            Assert.IsFalse(viewModel.IsExpired);
        }
        public void It_Should_Expire_PastExpireDates()
        {
            var viewModel = new AnnouncementViewModel("Body", "Title", DateTime.Now.AddDays(-1));

            Assert.IsTrue(viewModel.IsExpired);
        }
예제 #6
0
 public void SaveAnnouncement(AnnouncementViewModel viewModel)
 {
     _model.SaveAnnouncement(new AnnouncementDto(viewModel.Title, viewModel.Body, viewModel.Expires));
 }