public void Machine_Create_DoesCreate()
        {
            //Arrange

            InnerResource innerResource = new InnerResource();

            innerResource.Name = Guid.NewGuid().ToString();

            //Act

            innerResource.Create(DbContext);

            InnerResource        dbInnerResource = DbContext.InnerResources.AsNoTracking().First();
            List <InnerResource> machinelList    = DbContext.InnerResources.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(dbInnerResource);
            Assert.NotNull(dbInnerResource.Id);

            Assert.AreEqual(1, machinelList.Count());
            Assert.AreEqual(innerResource.CreatedAt.ToString(), dbInnerResource.CreatedAt.ToString());
            Assert.AreEqual(innerResource.Version, dbInnerResource.Version);
            Assert.AreEqual(innerResource.UpdatedAt.ToString(), dbInnerResource.UpdatedAt.ToString());
            Assert.AreEqual(dbInnerResource.WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(innerResource.CreatedByUserId, dbInnerResource.CreatedByUserId);
            Assert.AreEqual(innerResource.UpdatedByUserId, dbInnerResource.UpdatedByUserId);
            Assert.AreEqual(innerResource.Name, dbInnerResource.Name);
        }
Пример #2
0
        public void MachineAreaTimeRegistration_Create_DoesCreate()
        {
            //Arrange

            OuterResource outerResource = new OuterResource()
            {
                Name = Guid.NewGuid().ToString()
            };

            outerResource.Create(DbContext);

            InnerResource innerResource = new InnerResource()
            {
                Name = Guid.NewGuid().ToString()
            };

            innerResource.Create(DbContext);

            Random rnd = new Random();
            ResourceTimeRegistration matr = new ResourceTimeRegistration();

            matr.DoneAt          = DateTime.Now;
            matr.TimeInHours     = 10;
            matr.TimeInMinutes   = 60;
            matr.TimeInSeconds   = 100;
            matr.SDKCaseId       = rnd.Next(1, 100);
            matr.SDKSiteId       = rnd.Next(1, 100);
            matr.SDKFieldValueId = rnd.Next(1, 100);
            matr.OuterResourceId = outerResource.Id;
            matr.InnerResourceId = innerResource.Id;

            //Act

            matr.Create(DbContext);


            ResourceTimeRegistration        dbMatr   = DbContext.ResourceTimeRegistrations.AsNoTracking().First();
            List <ResourceTimeRegistration> matrList = DbContext.ResourceTimeRegistrations.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(dbMatr);

            Assert.AreEqual(matr.DoneAt.ToString(), dbMatr.DoneAt.ToString());
            Assert.AreEqual(matr.TimeInHours, dbMatr.TimeInHours);
            Assert.AreEqual(matr.TimeInMinutes, dbMatr.TimeInMinutes);
            Assert.AreEqual(matr.TimeInSeconds, dbMatr.TimeInSeconds);
            Assert.AreEqual(matr.SDKCaseId, dbMatr.SDKCaseId);
            Assert.AreEqual(matr.SDKSiteId, dbMatr.SDKSiteId);
            Assert.AreEqual(matr.SDKFieldValueId, dbMatr.SDKFieldValueId);
            Assert.AreEqual(matr.OuterResourceId, dbMatr.OuterResourceId);
            Assert.AreEqual(matr.InnerResourceId, dbMatr.InnerResourceId);

            Assert.AreEqual(1, matrList.Count());
        }
Пример #3
0
        public async Task <OperationResult> Create(InnerResourceModel model)
        {
            try
            {
                var innerResource = new InnerResource()
                {
                    Name       = model.Name,
                    ExternalId = model.ExternalId,
                };

                await innerResource.Create(_dbContext);

                model.Id = innerResource.Id;

                if (model.RelatedOuterResourcesIds != null)
                {
                    foreach (var outerResourceId in model.RelatedOuterResourcesIds)
                    {
                        var macth = await _dbContext.OuterInnerResources.SingleOrDefaultAsync(x =>
                                                                                              x.InnerResourceId == model.Id &&
                                                                                              x.OuterResourceId == outerResourceId);

                        if (macth == null)
                        {
                            var
                                outerInnerResource =
                                new Microting.eFormOuterInnerResourceBase.Infrastructure.Data.Entities.
                                OuterInnerResource
                            {
                                OuterResourceId = outerResourceId,
                                InnerResourceId = model.Id
                            };
                            await outerInnerResource.Create(_dbContext);
                        }
                    }
                    await _bus.SendLocal(new OuterInnerResourceCreate(model, null));
                }

                return(new OperationResult(true,
                                           _localizationService.GetString("InnerResourceCreatedSuccessfully", model.Name)));
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
                _logger.LogError(e.Message);
                return(new OperationResult(false,
                                           _localizationService.GetString("ErrorCreatingInnerResource")));
            }
        }
        public void MachineArea_Create_DoesCreate()
        {
            OuterResource outerResource = new OuterResource()
            {
                Name = Guid.NewGuid().ToString()
            };

            outerResource.Create(DbContext);

            InnerResource innerResource = new InnerResource()
            {
                Name = Guid.NewGuid().ToString()
            };

            innerResource.Create(DbContext);

            Random             rnd = new Random();
            OuterInnerResource outerInnerResource = new OuterInnerResource();

            outerInnerResource.OuterResourceId = outerResource.Id;
            outerInnerResource.InnerResourceId = innerResource.Id;

            //Act

            outerInnerResource.Create(DbContext);

            OuterInnerResource        dbOuterInnerResource = DbContext.OuterInnerResources.AsNoTracking().First();
            List <OuterInnerResource> machineAreaList      = DbContext.OuterInnerResources.AsNoTracking().ToList();

            //Assert

            Assert.NotNull(dbOuterInnerResource);
            Assert.NotNull(dbOuterInnerResource.Id);

            Assert.AreEqual(outerInnerResource.OuterResourceId, outerResource.Id);
            Assert.AreEqual(outerInnerResource.InnerResourceId, innerResource.Id);

            Assert.AreEqual(1, machineAreaList.Count());
            Assert.AreEqual(outerInnerResource.CreatedAt.ToString(), dbOuterInnerResource.CreatedAt.ToString());
            Assert.AreEqual(outerInnerResource.Version, dbOuterInnerResource.Version);
            Assert.AreEqual(outerInnerResource.UpdatedAt.ToString(), dbOuterInnerResource.UpdatedAt.ToString());
            Assert.AreEqual(dbOuterInnerResource.WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(outerInnerResource.CreatedByUserId, dbOuterInnerResource.CreatedByUserId);
            Assert.AreEqual(outerInnerResource.UpdatedByUserId, dbOuterInnerResource.UpdatedByUserId);
        }
        public async Task Machine_Save_DoesSave()
        {
            // Arrange
            InnerResource newInnerResource = new InnerResource
            {
                Name = Guid.NewGuid().ToString()
            };

            // Act
            await newInnerResource.Create(DbContext);

            InnerResource               innerResource     = DbContext.InnerResources.AsNoTracking().First();
            List <InnerResource>        innerResourceList = DbContext.InnerResources.AsNoTracking().ToList();
            List <InnerResourceVersion> versionList       = DbContext.InnerResourceVersions.AsNoTracking().ToList();

            // Assert
            Assert.NotNull(innerResource);
            Assert.AreEqual(1, innerResourceList.Count());
            Assert.AreEqual(1, versionList.Count());

            Assert.AreEqual(newInnerResource.Name, innerResource.Name);
        }
        public async Task EmployeesReportByDay_Generate_DoesGenerate()
        {
            OuterResource newArea = new OuterResource()
            {
                Name = "My OuterResource 1", Version = 1
            };
            OuterResource newArea1 = new OuterResource()
            {
                Name = "My OuterResource 2", Version = 1
            };
            OuterResource newArea2 = new OuterResource()
            {
                Name = "My OuterResource 3", Version = 1
            };
            InnerResource newMachine = new InnerResource()
            {
                Name = "My InnerResource 1", Version = 1
            };
            InnerResource newMachine1 = new InnerResource()
            {
                Name = "My InnerResource 2", Version = 1
            };
            InnerResource newMachine2 = new InnerResource()
            {
                Name = "My InnerResource 3", Version = 1
            };
            await newArea.Create(DbContext);

            await newArea1.Create(DbContext);

            await newArea2.Create(DbContext);

            await newMachine.Create(DbContext);

            await newMachine1.Create(DbContext);

            await newMachine2.Create(DbContext);

            // Different days
            ResourceTimeRegistration newTimeRegistrationDay = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 13)
            };
            ResourceTimeRegistration newTimeRegistrationDay1 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 14)
            };
            ResourceTimeRegistration newTimeRegistrationDay2 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea2.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine2.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 15)
            };
            ResourceTimeRegistration newTimeRegistrationDay3 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 13)
            };
            ResourceTimeRegistration newTimeRegistrationDay4 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 14)
            };
            ResourceTimeRegistration newTimeRegistrationDay5 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine2.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 15)
            };
            ResourceTimeRegistration newTimeRegistrationDay6 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 15)
            };

            await DbContext.ResourceTimeRegistrations.AddRangeAsync(newTimeRegistrationDay, newTimeRegistrationDay1,
                                                                    newTimeRegistrationDay2, newTimeRegistrationDay3, newTimeRegistrationDay4, newTimeRegistrationDay5,
                                                                    newTimeRegistrationDay6);

            await DbContext.SaveChangesAsync();

            GenerateReportModel model = new GenerateReportModel()
            {
                DateFrom     = new DateTime(2019, 5, 13),
                DateTo       = new DateTime(2019, 5, 16),
                Relationship = ReportRelationshipType.Employee,
                Type         = ReportType.Day
            };

            List <SiteDto> sitesList = new List <SiteDto>()
            {
                new SiteDto(1, "Test Site 1", "", "", 1, 1, 1, 1),
                new SiteDto(2, "Test Site 2", "", "", 1, 1, 1, 1)
            };

            DateTime modelDateFrom = new DateTime(
                model.DateFrom.Year,
                model.DateFrom.Month,
                model.DateFrom.Day,
                0, 0, 0);
            DateTime modelDateTo = new DateTime(
                model.DateTo.Year,
                model.DateTo.Month,
                model.DateTo.Day,
                23, 59, 59);

            List <ResourceTimeRegistration> jobsList = await DbContext.ResourceTimeRegistrations
                                                       .Include(x => x.InnerResource)
                                                       .Include(x => x.OuterResource)
                                                       .Where(x => x.DoneAt >= modelDateFrom && x.DoneAt <= modelDateTo)
                                                       .ToListAsync();

            ReportModel reportModel = ReportsHelper.GetReportData(model, jobsList, sitesList, (int)ReportTimeType.Minutes);

            Assert.AreEqual(reportModel.SubReports.Count, 1);
            Assert.AreEqual(reportModel.SubReports[0].TotalTime, 4200);
            Assert.AreEqual(reportModel.SubReports[0].Entities.Count, sitesList.Count);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].EntityName, sitesList[0].SiteName);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].EntityName, sitesList[1].SiteName);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TotalTime, 1800);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].TotalTime, 2400);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[0], 600);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[1], 600);
        }
        public async Task EmployeesReportByMonth_Generate_DoesGenerate()
        {
            OuterResource newArea = new OuterResource()
            {
                Name = "My OuterResource 1", Version = 1
            };
            OuterResource newArea1 = new OuterResource()
            {
                Name = "My OuterResource 2", Version = 1
            };
            OuterResource newArea2 = new OuterResource()
            {
                Name = "My OuterResource 3", Version = 1
            };
            InnerResource newMachine = new InnerResource()
            {
                Name = "My InnerResource 1", Version = 1
            };
            InnerResource newMachine1 = new InnerResource()
            {
                Name = "My InnerResource 2", Version = 1
            };
            InnerResource newMachine2 = new InnerResource()
            {
                Name = "My InnerResource 3", Version = 1
            };

            await newArea.Create(DbContext);

            await newArea1.Create(DbContext);

            await newArea2.Create(DbContext);

            await newMachine.Create(DbContext);

            await newMachine1.Create(DbContext);

            await newMachine2.Create(DbContext);

            // Different Month
            ResourceTimeRegistration newTimeRegistrationMonth = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 06, 13)
            };
            ResourceTimeRegistration newTimeRegistrationMonth1 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 07, 14)
            };
            ResourceTimeRegistration newTimeRegistrationMonth2 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea2.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine2.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 07, 15)
            };
            ResourceTimeRegistration newTimeRegistrationMonth3 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 08, 13)
            };
            ResourceTimeRegistration newTimeRegistrationMonth4 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 08, 14)
            };
            ResourceTimeRegistration newTimeRegistrationMonth5 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine2.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 09, 15)
            };
            ResourceTimeRegistration newTimeRegistrationMonth6 = new ResourceTimeRegistration()
            {
                OuterResourceId = newArea1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 09, 15)
            };

            await DbContext.ResourceTimeRegistrations.AddRangeAsync(newTimeRegistrationMonth, newTimeRegistrationMonth1,
                                                                    newTimeRegistrationMonth2, newTimeRegistrationMonth3, newTimeRegistrationMonth4, newTimeRegistrationMonth5,
                                                                    newTimeRegistrationMonth6);

            await DbContext.SaveChangesAsync();

            GenerateReportModel model = new GenerateReportModel()
            {
                DateFrom     = new DateTime(2019, 5, 13),
                DateTo       = new DateTime(2019, 9, 13),
                Relationship = ReportRelationshipType.Employee,
                Type         = ReportType.Month
            };

            List <SiteDto> sitesList = new List <SiteDto>()
            {
                // new SiteDto(1, "Test Site 1", "", "", 1, 1, 1, 1),
                new SiteDto()
                {
                    CustomerNo = 1,
                    Email      = "bla",
                    FirstName  = "Test",
                    LastName   = "Site 1",
                    OtpCode    = 1,
                    SiteId     = 1,
                    SiteName   = "Test Site 1",
                    UnitId     = 1,
                    WorkerUid  = 1
                },
                // new SiteDto(2, "Test Site 2", "", "", 1, 1, 1, 1)
                new SiteDto()
                {
                    CustomerNo = 1,
                    Email      = "bla",
                    FirstName  = "Test",
                    LastName   = "Site 2",
                    OtpCode    = 1,
                    SiteId     = 2,
                    SiteName   = "Test Site 2",
                    UnitId     = 1,
                    WorkerUid  = 1
                }
            };

            DateTime modelDateFrom = new DateTime(
                model.DateFrom.Year,
                model.DateFrom.Month,
                model.DateFrom.Day,
                0, 0, 0);
            DateTime modelDateTo = new DateTime(
                model.DateTo.Year,
                model.DateTo.Month,
                model.DateTo.Day,
                23, 59, 59);

            List <ResourceTimeRegistration> jobsList = await DbContext.ResourceTimeRegistrations
                                                       .Include(x => x.InnerResource)
                                                       .Include(x => x.OuterResource)
                                                       .Where(x => x.DoneAt >= modelDateFrom && x.DoneAt <= modelDateTo)
                                                       .ToListAsync();

            ReportModel reportModel = ReportsHelper.GetReportData(model, jobsList, sitesList, (int)ReportTimeType.Minutes);

            Assert.AreEqual(reportModel.SubReports.Count, 1);
            Assert.AreEqual(reportModel.SubReports[0].TotalTime, 3000);
            Assert.AreEqual(reportModel.SubReports[0].Entities.Count, sitesList.Count);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].EntityName, sitesList[0].SiteName);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].EntityName, sitesList[1].SiteName);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TotalTime, 1800);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].TotalTime, 1200);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[0], 0);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[1], 600);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[2], 1200);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[3], 0);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[4], 0);
        }
Пример #8
0
        public async Task OuterResourcesReportByWeek_Generate_DoesGenerate()
        {
            OuterResource newOuterResource = new OuterResource()
            {
                Name = "My OuterResource 1", Version = 1
            };
            OuterResource newOuterResource1 = new OuterResource()
            {
                Name = "My OuterResource 2", Version = 1
            };
            OuterResource newOuterResource2 = new OuterResource()
            {
                Name = "My OuterResource 3", Version = 1
            };
            InnerResource newMachine = new InnerResource()
            {
                Name = "My InnerResource 1", Version = 1
            };
            InnerResource newMachine1 = new InnerResource()
            {
                Name = "My InnerResource 2", Version = 1
            };
            InnerResource newMachine2 = new InnerResource()
            {
                Name = "My InnerResource 3", Version = 1
            };

            await newOuterResource.Create(DbContext);

            await newOuterResource1.Create(DbContext);

            await newOuterResource2.Create(DbContext);

            await newMachine.Create(DbContext);

            await newMachine1.Create(DbContext);

            await newMachine2.Create(DbContext);

            // Different Weeks
            ResourceTimeRegistration newTimeRegistrationWeek = new ResourceTimeRegistration()
            {
                OuterResourceId = newOuterResource.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 20)
            };
            ResourceTimeRegistration newTimeRegistrationWeek1 = new ResourceTimeRegistration()
            {
                OuterResourceId = newOuterResource1.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 20)
            };
            ResourceTimeRegistration newTimeRegistrationWeek2 = new ResourceTimeRegistration()
            {
                OuterResourceId = newOuterResource2.Id, Version = 1, SDKSiteId = 1, InnerResourceId = newMachine2.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 05, 27)
            };
            ResourceTimeRegistration newTimeRegistrationWeek3 = new ResourceTimeRegistration()
            {
                OuterResourceId = newOuterResource.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 06, 27)
            };
            ResourceTimeRegistration newTimeRegistrationWeek4 = new ResourceTimeRegistration()
            {
                OuterResourceId = newOuterResource1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 06, 05)
            };
            ResourceTimeRegistration newTimeRegistrationWeek5 = new ResourceTimeRegistration()
            {
                OuterResourceId = newOuterResource1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine2.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 06, 05)
            };
            ResourceTimeRegistration newTimeRegistrationWeek6 = new ResourceTimeRegistration()
            {
                OuterResourceId = newOuterResource1.Id, Version = 1, SDKSiteId = 2, InnerResourceId = newMachine1.Id, TimeInSeconds = 36000, DoneAt = new DateTime(2019, 06, 06)
            };

            await DbContext.ResourceTimeRegistrations.AddRangeAsync(newTimeRegistrationWeek, newTimeRegistrationWeek1,
                                                                    newTimeRegistrationWeek2, newTimeRegistrationWeek3, newTimeRegistrationWeek4, newTimeRegistrationWeek5,
                                                                    newTimeRegistrationWeek6);

            await DbContext.SaveChangesAsync();

            GenerateReportModel model = new GenerateReportModel()
            {
                DateFrom     = new DateTime(2019, 5, 13),
                DateTo       = new DateTime(2019, 6, 07),
                Relationship = ReportRelationshipType.OuterResource,
                Type         = ReportType.Week
            };

            List <SiteDto> sitesList = new List <SiteDto>()
            {
                new SiteDto(1, "Test Site 1", "", "", 1, 1, 1, 1),
                new SiteDto(2, "Test Site 2", "", "", 1, 1, 1, 1)
            };

            DateTime modelDateFrom = new DateTime(
                model.DateFrom.Year,
                model.DateFrom.Month,
                model.DateFrom.Day,
                0, 0, 0);
            DateTime modelDateTo = new DateTime(
                model.DateTo.Year,
                model.DateTo.Month,
                model.DateTo.Day,
                23, 59, 59);

            List <ResourceTimeRegistration> jobsList = await DbContext.ResourceTimeRegistrations
                                                       .Include(x => x.InnerResource)
                                                       .Include(x => x.OuterResource)
                                                       .Where(x => x.DoneAt >= modelDateFrom && x.DoneAt <= modelDateTo)
                                                       .ToListAsync();

            ReportModel reportModel = ReportsHelper.GetReportData(model, jobsList, sitesList, (int)ReportTimeType.Minutes);

            Assert.AreEqual(reportModel.SubReports.Count, 1);
            Assert.AreEqual(reportModel.SubReports[0].TotalTime, 3600);
            Assert.AreEqual(reportModel.SubReports[0].Entities.Count, 3);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].EntityName, newOuterResource.Name);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].EntityName, newOuterResource1.Name);
            Assert.AreEqual(reportModel.SubReports[0].Entities[2].EntityName, newOuterResource2.Name);

            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TotalTime, 600);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].TotalTime, 2400);

            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[0], 0);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[1], 600);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[2], 0);
            Assert.AreEqual(reportModel.SubReports[0].Entities[0].TimePerTimeUnit[3], 0);

            Assert.AreEqual(reportModel.SubReports[0].Entities[1].TimePerTimeUnit[0], 0);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].TimePerTimeUnit[1], 600);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].TimePerTimeUnit[2], 0);
            Assert.AreEqual(reportModel.SubReports[0].Entities[1].TimePerTimeUnit[3], 1800);
        }