Esempio n. 1
0
        public void CreateTMEventTestDatePastValidation()
        {
            List <TMEvent> events = new List <TMEvent>();

            events.Add(new TMEvent
            {
                Id          = 1,
                Name        = "a",
                Description = "d",
                StartEvent  = DateTime.Now.Date.AddDays(1),
                EndEvent    = DateTime.Now.Date.AddDays(2),
            });
            events.Add(new TMEvent
            {
                Id          = 2,
                Name        = "a2",
                Description = "d2",
                StartEvent  = DateTime.Now.Date.AddDays(3),
                EndEvent    = DateTime.Now.Date.AddDays(4),
            });

            Mock <ITMEventRepository> mockTMEventRepository = new Mock <ITMEventRepository>();

            mockTMEventRepository.Setup(x => x.GetAll()).Returns(events);

            Mock <ITMEventAreaService> mockTMEventAreaService = new Mock <ITMEventAreaService>();
            Mock <ITMEventSeatService> mockTMEventSeatService = new Mock <ITMEventSeatService>();

            TMEventService tmeventService = new TMEventService(mockTMEventRepository.Object,
                                                               mockTMEventAreaService.Object, mockTMEventSeatService.Object);

            TMEventDto tmeventPre_dto = new TMEventDto
            {
                Name        = "a",
                Description = "d",
                StartEvent  = DateTime.Now.Date.AddDays(-1),
                EndEvent    = DateTime.Now.Date,
            };

            TMEventDto tmeventPast = tmeventPre_dto;

            tmeventService.CreateTMEvent(tmeventPre_dto);

            tmeventPast.Should().BeEquivalentTo(tmeventPre_dto);
        }
Esempio n. 2
0
        public void CreateTMEventTestSameObject()
        {
            List <TMEvent> events = new List <TMEvent>();

            events.Add(new TMEvent
            {
                Id          = 1,
                Name        = "a",
                Description = "d",
                StartEvent  = DateTime.Now.Date.AddDays(1),
                EndEvent    = DateTime.Now.Date.AddDays(2),
            });
            events.Add(new TMEvent
            {
                Id          = 2,
                Name        = "a2",
                Description = "d2",
                StartEvent  = DateTime.Now.Date.AddDays(3),
                EndEvent    = DateTime.Now.Date.AddDays(4),
            });

            List <TMEventDto> events_dto = new List <TMEventDto>();

            events_dto.Add(new TMEventDto
            {
                Id          = 1,
                Name        = "a",
                Description = "d",
                StartEvent  = DateTime.Now.Date.AddDays(1),
                EndEvent    = DateTime.Now.Date.AddDays(2),
            });
            events_dto.Add(new TMEventDto
            {
                Id          = 2,
                Name        = "a2",
                Description = "d2",
                StartEvent  = DateTime.Now.Date.AddDays(3),
                EndEvent    = DateTime.Now.Date.AddDays(4),
            });

            Mock <ITMEventRepository> mockTMEventRepository = new Mock <ITMEventRepository>();

            mockTMEventRepository.Setup(x => x.GetAll()).Returns(events);

            Mock <ITMEventAreaService> mockTMEventAreaService = new Mock <ITMEventAreaService>();

            mockTMEventAreaService.Setup(x => x.GetAllTMEventArea())
            .Returns(new List <TMEventAreaDto> {
                new TMEventAreaDto {
                    TMEventId = 1, Id = 1
                }
            });

            Mock <ITMEventSeatService> mockTMEventSeatService = new Mock <ITMEventSeatService>();

            mockTMEventSeatService.Setup(x => x.GetAllTMEventSeat())
            .Returns(new List <TMEventSeatDto> {
                new TMEventSeatDto {
                    TMEventAreaId = 1, Id = 1
                }
            });

            TMEventService tmeventService = new TMEventService(mockTMEventRepository.Object,
                                                               mockTMEventAreaService.Object, mockTMEventSeatService.Object);

            TMEventDto tmevent = new TMEventDto
            {
                Name        = "a",
                Description = "d",
                StartEvent  = DateTime.Now.Date.AddDays(1),
                EndEvent    = DateTime.Now.Date.AddDays(2),
            };

            tmeventService.CreateTMEvent(tmevent);

            tmevent.Should().BeEquivalentTo(events_dto[0]);
        }