Exemple #1
0
        public void GetGrmEvent_CallsRepository_ValidMissingIdIsPassedToRepository_NotFoundExceptionIsThrown()
        {
            var moqRepository = new Mock <IGrmEventRepository>();

            var grmEventDomain = new GrmEventDomain(moqRepository.Object);

            Should.Throw <RecordNotFoundException>(() => grmEventDomain.Get(22));

            moqRepository.Verify(x => x.Get(22));
        }
Exemple #2
0
        public void GetGrmEvents_NoListReturned_GetRecordNotFoundException()
        {
            var moqRepository = new Mock <IGrmEventRepository>();

            moqRepository.Setup(x => x.GetGrmEventInfo(new[] { 12, 13 })).Returns(() => new List <Repository.Models.V1.GrmEventInformation>());

            var grmEventDomain = new GrmEventDomain(moqRepository.Object);

            Should.Throw <RecordNotFoundException>(() => grmEventDomain.GetGrmEventInfo(new[] { 12, 13 }));
        }
Exemple #3
0
        public void CreateGrmEventWithValidCreateInput()
        {
            var grmEventListCreate = CreateMockDto();
            var moqRepository      = new Mock <IGrmEventRepository>();

            moqRepository.Setup(x => x.CreateGrmEvents(It.IsAny <IEnumerable <GrmEventComponentCreate> >())).Returns(Mapping.Mappers.ToEntity(grmEventListCreate.GrmEventList));
            var grmEventDomain = new GrmEventDomain(moqRepository.Object);

            var grmEventListResult = grmEventDomain.CreateGrmEvents(grmEventListCreate);

            grmEventListResult.ShouldNotBeNull();
            grmEventListResult.GrmEventList.Count.ShouldBe(1);
        }
Exemple #4
0
        public void GetGrmEvent_CallsRepository_ValidRecordIsReturnedFromRepository_RecordIsReturned()
        {
            var grmEvent = new Repository.Models.V1.GrmEvent()
            {
                Id = 999
            };
            var moqRepository = new Mock <IGrmEventRepository>();

            moqRepository.Setup(x => x.Get(999)).Returns(grmEvent);

            var grmEventDomain = new GrmEventDomain(moqRepository.Object);
            var returnGrmEvent = grmEventDomain.Get(999);

            returnGrmEvent.Id.ShouldBe(grmEvent.Id);
        }
Exemple #5
0
        public void GetGrmEvents_EntitiesReturned_GetDtos()
        {
            var moqRepository = new Mock <IGrmEventRepository>();

            moqRepository.Setup(x => x.GetGrmEventInfo(new[] { 12, 13 })).Returns(() => new List <Repository.Models.V1.GrmEventInformation>
            {
                new Repository.Models.V1.GrmEventInformation
                {
                    GrmEventId      = 12,
                    Description     = "First Unit Test GRM Event",
                    EffectiveDate   = new DateTime(2015, 2, 1),
                    RevenueObjectId = 100,
                    EventType       = "First Unit Test Event Type",
                    EventDate       = new DateTime(2015, 1, 1)
                },
                new Repository.Models.V1.GrmEventInformation
                {
                    GrmEventId      = 13,
                    Description     = "Second Unit Test GRM Event",
                    EffectiveDate   = new DateTime(2016, 2, 1),
                    RevenueObjectId = 200,
                    EventType       = "Second Unit Test Event Type",
                    EventDate       = new DateTime(2016, 1, 1)
                }
            });

            var grmEventDomain = new GrmEventDomain(moqRepository.Object);

            var list = grmEventDomain.GetGrmEventInfo(new[] { 12, 13 }).ToList();

            list.Count.ShouldBe(2);
            list[0].GrmEventId.ShouldBe(12);
            list[1].GrmEventId.ShouldBe(13);

            var grmEvent1 = list[0];

            grmEvent1.Description.ShouldBe("First Unit Test GRM Event");
            grmEvent1.EffectiveDate.ShouldBe(new DateTime(2015, 2, 1));
            grmEvent1.RevenueObjectId.ShouldBe(100);
            grmEvent1.EventType.ShouldBe("First Unit Test Event Type");
            grmEvent1.EventDate.ShouldBe(new DateTime(2015, 1, 1));
        }
Exemple #6
0
        public void GetGrmEvents_OneIdInListIs0_GetBadRequestException()
        {
            var grmEventDomain = new GrmEventDomain(null);

            Should.Throw <BadRequestException>(() => grmEventDomain.GetGrmEventInfo(new[] { 12, 0 }));
        }
Exemple #7
0
        public void GetGrmEvent_CallsRepository_InvalidIdIsPassedToRepository_BadRequestExceptionIsThrown()
        {
            var grmEventDomain = new GrmEventDomain(null);

            Should.Throw <BadRequestException>(() => grmEventDomain.Get(-1));
        }
Exemple #8
0
 public GrmEventDomainTests()
 {
     _mockGrmEventRepository = new Mock <IGrmEventRepository>();
     _grmEventDomain         = new GrmEventDomain(_mockGrmEventRepository.Object);
 }