コード例 #1
0
        public async Task UploadShifts_CsvFile_AddShifts()
        {
            // Arrange
            IRepository <Shift>        shiftRepository        = Substitute.For <IRepository <Shift> >();
            IRepository <Organization> organizationRepository = Substitute.For <IRepository <Organization> >();

            Microsoft.Graph.IGraphServiceClient graphServiceClient = Substitute.For <Microsoft.Graph.IGraphServiceClient>();
            IStringLocalizer <ShiftController>  stringLocalizer    = Substitute.For <IStringLocalizer <ShiftController> >();


            ShiftController     controller = new ShiftController(shiftRepository, organizationRepository, graphServiceClient, stringLocalizer);
            FileUploadViewModel viewModel  = new FileUploadViewModel {
                StoreName = "Contoso"
            };
            string content = "Start, End, Type\n2020-04-10T09:00,2020-04-10T17:00,Shelf Stacker\n2020-04-10T10:00,2020-04-10T18:00,Tills";

            byte[] contentBytes = Encoding.UTF8.GetBytes(content);

            viewModel.FormFile = new FormFile(new MemoryStream(contentBytes), 0, contentBytes.Length, null, "shifts.csv")
            {
                Headers     = new HeaderDictionary(),
                ContentType = "csv"
            };


            // Act
            await controller.UploadShifts(viewModel);


#pragma warning disable 4014
            // Assert
            shiftRepository.Received(1).Add(Arg.Is <Shift>(x => x.Start == DateTime.Parse("2020-04-10T09:00")));
            shiftRepository.Received(1).Add(Arg.Is <Shift>(x => x.Start == DateTime.Parse("2020-04-10T10:00")));
#pragma warning restore 4014
        }
コード例 #2
0
 public ShiftController(
     IRepository <Shift> shiftRepository,
     IRepository <Organization> organizationRepository,
     Microsoft.Graph.IGraphServiceClient graphServiceClient,
     IStringLocalizer <ShiftController> stringLocalizer)
 {
     this.shiftRepository        = shiftRepository;
     this.organizationRepository = organizationRepository;
     this.graphServiceClient     = graphServiceClient;
     this.stringLocalizer        = stringLocalizer;
 }
コード例 #3
0
 public ShiftsController(
     IRepository <Shift> shiftRepository,
     ILocationService locationService,
     Microsoft.Graph.IGraphServiceClient graphServiceClient,
     IStringLocalizer <ShiftsController> stringLocalizer,
     IConfiguration configuration,
     IMapService mapService,
     ILogger <ShiftsController> logger)
 {
     this.shiftRepository    = shiftRepository;
     this.locationService    = locationService;
     this.graphServiceClient = graphServiceClient;
     this.stringLocalizer    = stringLocalizer;
     this.configuration      = configuration;
     this.mapService         = mapService;
     this.logger             = logger;
 }