public void GetAllByCalendarId_WithCorrectData_ShouldReturnCorrectResult() { var calendar = new Calendar { Id = "Test1", Title = "Default", }; var color = new Color { Id = 1, Name = "Test", Hex = "TestHex", }; var model = new Event { Id = "Test1", Title = "Test", StartDateTime = new DateTime(2020, 02, 02, 12, 0, 0), EndDateTime = new DateTime(2020, 02, 02, 12, 30, 0), Description = "test description", Location = "Hotel Test", Coordinates = "42.99, 32.99", Calendar = calendar, CalendarId = calendar.Id, Color = color, }; var eventCalendarViewModel = new EventCalendarViewModel { Id = "Test1", Title = "Test", StartDateTime = new DateTime(2020, 02, 02, 12, 0, 0), EndDateTime = new DateTime(2020, 02, 02, 12, 30, 0), CalendarId = "Test1", Description = "test description", Location = "Hotel Test", Coordinates = "42.99, 32.99", ColorHex = color.Hex, }; this.eventsRepository.Setup(x => x.All()).Returns(new List <Event> { model }.AsQueryable()); var actualResultColleciton = this.eventService.GetAllByCalendarId(calendar.Id); var expectedResult = eventCalendarViewModel; var actualResult = actualResultColleciton.First(); this.eventsRepository.Verify(x => x.All(), Times.Once); Assert.Single(actualResultColleciton); Assert.Equal(expectedResult.Title, actualResult.Title); Assert.Equal(expectedResult.StartDateTime, actualResult.StartDateTime); Assert.Equal(expectedResult.EndDateTime, actualResult.EndDateTime); }
public void EventCalendarViewModelShouldHaveTitle() { var eventToTest = new EventCalendarViewModel { Title = null, Start = DateTime.UtcNow, Description = "ddd", Color = "sss", End = DateTime.Now, IsAllDay = false, }; var validatorResults = new List <ValidationResult>(); var actual = Validator.TryValidateObject(eventToTest, new ValidationContext(eventToTest), validatorResults, true); Assert.False(actual); Assert.Single(validatorResults); }