Exemple #1
0
        public void Should_List_Shifts()
        {
            var shiftRelatedIds = Create_Shift_For_List_Tests_And_Return_Ids();

            var date = DateTime.Now;

            context.Shifts.Add(new Domain.Shift
            {
                Id             = Guid.NewGuid(),
                Start          = date,
                End            = date.AddHours(8),
                TechnologistId = shiftRelatedIds.TechnologistId1,
                ModalityId     = shiftRelatedIds.ModalityId,
                LicenseId      = shiftRelatedIds.LicenseId1,
                LocationId     = shiftRelatedIds.LocationId,
                RoomId         = shiftRelatedIds.RoomId
            });

            context.Shifts.Add(new Domain.Shift
            {
                Id             = Guid.NewGuid(),
                Start          = date,
                End            = date.AddHours(8),
                TechnologistId = shiftRelatedIds.TechnologistId2,
                ModalityId     = shiftRelatedIds.ModalityId,
                LicenseId      = shiftRelatedIds.LicenseId1,
                LocationId     = shiftRelatedIds.LocationId,
                RoomId         = shiftRelatedIds.RoomId
            });

            context.SaveChanges();

            var sut = new List.Handler(context, _mapper);

            var result = sut.Handle(new List.Query(filterDate: date, filterLicense: null, filterLocation: null, filterModality: null, filterTechnologist: null, monthFlag: null), CancellationToken.None).Result;

            Assert.Equal(2, result.Count);
        }
        public async Task GetBrands()
        {
            var dbContenxt = await GetDatabaseContext();

            // var brandvms = new List<BrandVm>();
            var mapper = new Mock <IMapper>();

            mapper.Setup(m => m.Map <List <Brand>, List <BrandVm> >(It.IsAny <List <Brand> >()))
            .Returns((List <Brand> src) =>
                     src.Select(x => new BrandVm {
                Id = x.Id, Name = x.Name
            })
                     .ToList());

            var query = new List.Query();

            var handler = new List.Handler(dbContenxt, mapper.Object);

            var result = handler.Handle(query, new CancellationToken());

            var actionResult = Assert.IsType <List <BrandVm> >(result.Result.Value);

            Assert.NotEmpty(actionResult);
        }
 public ListTest()
 {
     trailServiceMock = new Mock <ITrailsService>();
     listHandler      = new List.Handler(trailServiceMock.Object);
 }
Exemple #4
0
        public void Should_List_Technologists()
        {
            var context     = GetDbContext();
            var modalityId1 = Guid.NewGuid();
            var modalityId2 = Guid.NewGuid();

            context.Modalities.Add(new Domain.Modality {
                Id = modalityId1, Name = "Test Modality 1", DisplayName = "TM1"
            });
            context.Modalities.Add(new Domain.Modality {
                Id = modalityId2, Name = "Test Modality 2", DisplayName = "TM2"
            });
            context.SaveChanges();

            var technologistId1 = Guid.NewGuid();
            var technologistId2 = Guid.NewGuid();
            var technologistId3 = Guid.NewGuid();

            //two technologists with same modality
            context.Technologists.Add(new Domain.Technologist
            {
                Id         = technologistId1,
                Name       = "Technologist 1",
                ModalityId = modalityId1,
                Initial    = "T1"
            });


            context.Technologists.Add(new Domain.Technologist
            {
                Id         = technologistId2,
                Name       = "Technologist 2",
                ModalityId = modalityId1,
                Initial    = "T2"
            });

            //one technologist with a different modality

            context.Technologists.Add(new Domain.Technologist
            {
                Id         = technologistId3,
                Name       = "Technologist 3",
                ModalityId = modalityId2,
                Initial    = "T3"
            });



            context.SaveChanges();

            var sut = new List.Handler(context, _mapper);

            var result = sut.Handle(new List.Query(modalityId1), CancellationToken.None).Result;

            var technologistExists       = result.Any(x => x.Name == "Technologist 1");
            var technologistDoesNotExist = result.Any(x => x.Name == "Technologist 3");

            Assert.Equal(2, result.Count);
            Assert.True(technologistExists);
            Assert.False(technologistDoesNotExist);
        }