Пример #1
0
 public PowerGuideServiceImpl(PowerGuideAuthenticationService authentication, InstallationService installationService,
                              MeasurementService measurementService)
 {
     this.authentication = authentication;
     installation        = installationService;
     measurement         = measurementService;
 }
Пример #2
0
        public void TestGetByDate_ThereIsEntry_ShouldReturnCorrectly(string userId, int day, int month, int year)
        {
            // Arrange
            var date        = new DateTime(year, month, day);
            var measurement = new Measurement {
                Date = date, UserId = userId
            };

            var results = new List <Measurement> {
                measurement
            };

            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();

            mockedMeasurementRepository.Setup(r => r.All).Returns(results.AsQueryable());

            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var mockedFactory    = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            var result = service.GetByDate(userId, date);

            // Assert
            Assert.AreSame(measurement, result);
        }
Пример #3
0
 public MeasurementAppService(MeasurementService domainService, IJointsRepo joints, IMissionRepo missions, IMeasurementRepo measurements)
 {
     this.domainService = domainService;
     this.joints        = joints;
     this.missions      = missions;
     this.measurements  = measurements;
 }
Пример #4
0
        public void TestGetUserMeasurementsSortedByDate_ShouldFilterAndReturnCorrectly(string userId)
        {
            // Arrange
            var measurements = new List <Measurement>
            {
                new Measurement {
                    UserId = userId
                },
                new Measurement {
                    UserId = userId
                },
                new Measurement()
            }.AsQueryable();

            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();

            mockedMeasurementRepository.Setup(r => r.All).Returns(measurements);

            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var mockedFactory    = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            var expected = measurements.Where(m => m.UserId == userId);

            // Act
            var result = service.GetUserMeasurementsSortedByDate(userId);

            // Assert
            CollectionAssert.AreEqual(expected, result);
        }
Пример #5
0
        public void CreateLanes(List <int> competitorsId, int contestId, Match match)
        {
            var database = new DataBaseRepo();

            var unitService = new MeasurementService();
            var unit        = unitService.WhatUnitDoYouNeedBro("spelare");
            //TODO Bygga upp serier genom lane, även få med båda spelarnas ID:n så att det skapas en separat serie per spelare.
            var quantity = (DatabaseHolder)database.Save
                               (new Quantity
            {
                Amount = 2,
                UnitId = unit.UnitId
            });

            if (quantity.ExecuteCodes == ExecuteCodes.SuccessToExecute)
            {
                var lane = new Lane
                {
                    UnitId     = unit.UnitId,
                    QuantityId = quantity.PrimaryKey
                };

                var primaryKeyLane = (DatabaseHolder)database.Save(lane);
                match.LaneId     = primaryKeyLane.PrimaryKey;
                match.QuantityId = quantity.PrimaryKey;
                match.UnitId     = unit.UnitId;
                var matchId = (DatabaseHolder)database.Save(match);
                if (matchId.ExecuteCodes != ExecuteCodes.FailedToExecute)
                {
                    lane.CreateSerie(primaryKeyLane.PrimaryKey, contestId, competitorsId);
                }
            }
        }
Пример #6
0
        public static DataTable MapCollectionToDataTable <T>(IEnumerable <T> collection) where T : IBaseEntity
        {
            DataTable dt = CreateTable <T>();

            foreach (var itm in collection)
            {
                DataRow dr = dt.NewRow();

                if (typeof(T) == typeof(Product))
                {
                    dr["ID"]          = itm.ID;
                    dr["Name"]        = itm.DisplayName;
                    dr["Price"]       = ((IProduct)itm).ItemPrice;
                    dr["Measurement"] = new MeasurementService()
                                        .FindByID((int)((IProduct)itm).ProdMeasurementID).Description;
                }
                if (typeof(T) == typeof(Tax))
                {
                    dr["ID"]      = itm.ID;
                    dr["Name"]    = itm.DisplayName;
                    dr["TaxRate"] = ((ITax)itm).Rate;
                }
                else
                {
                    dr["ID"]   = itm.ID;
                    dr["Name"] = itm.DisplayName;
                }

                dt.Rows.Add(dr);
            }

            return(dt);
        }
Пример #7
0
        public void TestCreateMeasurement_ShouldCallRepositoryAll(int height,
                                                                  double weightKg,
                                                                  double bodyFatPercent,
                                                                  int chest,
                                                                  int shoulders,
                                                                  int forearm,
                                                                  int arm,
                                                                  int waist,
                                                                  int hips,
                                                                  int thighs,
                                                                  int calves,
                                                                  int neck,
                                                                  int wrist,
                                                                  int ankle,
                                                                  string userId)
        {
            // Arrange
            var date = new DateTime(2, 3, 4);

            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();
            var mockedUnitOfWork            = new Mock <IUnitOfWork>();
            var mockedFactory = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            service.CreateMeasurement(height, weightKg, bodyFatPercent, chest, shoulders, forearm, arm, waist, hips, thighs,
                                      calves, neck, wrist, ankle, userId, date);

            // Assert
            mockedMeasurementRepository.Verify(r => r.All, Times.Once);
        }
        /// <summary>
        /// Constructor to initialize variables
        /// </summary>
        public MeteorologyReportTests()
        {
            serviceMock = new Mock <IMeasurementService>();
            controller  = new DevicesController(serviceMock.Object);

            repoMock = new Mock <IBlobStorage>();
            service  = new MeasurementService(repoMock.Object);
        }
        public static IMeasurementService GetMeasurementInstance()
        {
            IDbContext dbContext = new ProjectDataContext("Project.Data.ProjectDataContext");
            IRepository <Measurement> measurementService  = new EfRepository <Measurement>(dbContext);
            IMeasurementService       measurementService1 = new  MeasurementService(measurementService, new MemoryCacheManager());

            return(measurementService1);
        }
        public void CheckPlainSection()
        {
            MeasurementService s = new MeasurementService(this.graphics);
            Rectangle          r = new Rectangle(section.Location, section.Size);

            s.FitSectionToItems(this.section);
            Assert.AreEqual(r.Location, s.Rectangle.Location);
        }
Пример #11
0
 public Aspose3DMeasurementController(StorageService storageService,
                                      MeasurementService measurementService,
                                      StatsService statsService,
                                      ILoggerFactory loggerFactory) : base(measurementService, storageService, loggerFactory, ThreeDApp.Measurement, statsService)
 {
     OpUpload   = CreateOperationKind("upload");
     OpReview   = CreateOperationKind("review");
     OpDownload = CreateOperationKind("download");
 }
Пример #12
0
        public void GetAUnitByName()
        {
            MeasurementService sut = new MeasurementService();
            var result             = sut.WhatUnitDoYouNeedBro("SpElare");
            var unit = new Unit {
                Name = "Spelare"
            };

            Assert.Equal(unit.Name, result.Name);
        }
Пример #13
0
        /// <summary>
        /// Prevents a default instance of the <see cref="Database"/> class from being created.
        /// Use <see cref="Database.Instance"/> to access the Singleton.
        /// </summary>
        /// <param name="filePath">The file path providing the database configuration file.</param>
        private Database(string filePath)
        {
            database = PgDb.Create(filePath);

            // Init services

            playerService = PlayerService.GetInstance(database);
            teamService = TeamService.GetInstance(database);
            measurementService = MeasurementService.GetInstance(database);
            featureCategoryService = FeatureCategoryService.GetInstance(database);
        }
Пример #14
0
 private void frmAddBrand_Load(object sender, EventArgs e)
 {
     if (_entityState == EntityState.Dirty)
     {
         Entities.Measurement measurement = new MeasurementService().GetSingle(new Measurement {
             Id = MeasurementID
         });
         txtComment.Text = measurement.Description;
         txtName.Text    = measurement.Name;
     }
 }
Пример #15
0
 public CommonController(
     MeasurementService measurementService,
     ConholdateService conholdateService,
     StorageService storageService,
     ILoggerFactory loggerFactory
     )
 {
     this.storageService    = storageService;
     this.conholdateService = conholdateService;
     error2forum            = measurementService.CreateMeasurement(ThreeDApp.Common);
     logger = loggerFactory.CreateLogger <CommonController>();
 }
Пример #16
0
        public Aspose3DRepairingController(
            StorageService storageService,
            MeasurementService measurementService,
            ILoggerFactory loggerFactory,
            StatsService statsService
            )
            : base(measurementService, storageService, loggerFactory, ThreeDApp.Repairing, statsService)
        {
            _logger = loggerFactory.CreateLogger <Aspose3DRepairingController>();

            OpReview = CreateOperationKind("review");
            OpRepair = CreateOperationKind("repair");
            OpUpload = CreateOperationKind("upload");
        }
        public void ReportItemFitInSection()
        {
            MeasurementService s = new MeasurementService(this.graphics);
            Rectangle          r = new Rectangle(section.Location, section.Size);

            this.section.Items.Clear();
            BaseReportItem item = new BaseReportItem();

            item.Location = new Point(10, 10);
            item.Size     = new Size(50, 50);
            this.section.Items.Add(item);
            s.FitSectionToItems(this.section);
            Assert.AreEqual(r.Location, s.Rectangle.Location);
        }
Пример #18
0
        public void TestConstructor_PassEverything_ShouldInitializeCorrectly()
        {
            // Arrange
            var mockedRepository         = new Mock <IRepository <Measurement> >();
            var mockedUnitOfWork         = new Mock <IUnitOfWork>();
            var mockedMeasurementFactory = new Mock <IMeasurementFactory>();

            // Act
            var service = new MeasurementService(mockedRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedMeasurementFactory.Object);

            // Assert
            Assert.IsNotNull(service);
        }
        public AsposeAppControllerBase(MeasurementService measurementService,
                                       StorageService storageService,
                                       ILoggerFactory loggerFactory,
                                       ThreeDApp app,
                                       StatsService statsService
                                       )
        {
            this.app           = app;
            this.statsService  = statsService;
            measurement        = measurementService.CreateMeasurement(app);
            _storageRepository = storageService.GetRepository(app.ToString().ToLower());


            _logger = loggerFactory.CreateLogger(GetType());
        }
Пример #20
0
        public InputPage()
        {
            InitializeComponent();

            measurementService = new MeasurementService();

            var vm = new InputPageViewModel();

            vm.ID            = Guid.NewGuid();
            vm.Name          = "Testing for fun";
            vm.Value         = 200.00;
            vm.UoM           = "cm";
            vm.Timestamp     = DateTime.Now;
            this.DataContext = vm;
        }
 public CourseController(
     PMDbContext context,
     CourseService courseService,
     MedicineService medicineService,
     ProcedureService procedureService,
     MeasurementService measurementService,
     CourseHistoryService courseHistoryService)
 {
     _context              = context;
     _courseService        = courseService;
     _medicineService      = medicineService;
     _procedureService     = procedureService;
     _measurementService   = measurementService;
     _courseHistoryService = courseHistoryService;
 }
        public Aspose3DConversionController(IConfiguration configuration,
                                            StorageService storageService,
                                            MeasurementService measurementService,
                                            StatsService statsService,
                                            ILoggerFactory loggerFactory)
            : base(measurementService, storageService, loggerFactory, ThreeDApp.Conversion, statsService)
        {
            _configuration    = configuration;
            this.statsService = statsService;


            OpUpload   = CreateOperationKind("upload");
            OpConvert  = CreateOperationKind("convert");
            OpDownload = CreateOperationKind("download");
            OpEmail    = CreateOperationKind("email");
        }
Пример #23
0
        public void TestCreateMeasurement_RepositoryReturnsMeasurement_ShouldNotCallFactoryCreateMeasurement(int height,
                                                                                                             double weightKg,
                                                                                                             double bodyFatPercent,
                                                                                                             int chest,
                                                                                                             int shoulders,
                                                                                                             int forearm,
                                                                                                             int arm,
                                                                                                             int waist,
                                                                                                             int hips,
                                                                                                             int thighs,
                                                                                                             int calves,
                                                                                                             int neck,
                                                                                                             int wrist,
                                                                                                             int ankle,
                                                                                                             string userId)
        {
            // Arrange
            var date = new DateTime(2, 3, 4);

            var measurement = new Measurement {
                Date = date, UserId = userId
            };

            var results = new List <Measurement> {
                measurement
            };

            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();

            mockedMeasurementRepository.Setup(r => r.All).Returns(results.AsQueryable());

            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var mockedFactory    = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            service.CreateMeasurement(height, weightKg, bodyFatPercent, chest, shoulders, forearm, arm, waist, hips, thighs,
                                      calves, neck, wrist, ankle, userId, date);

            // Assert
            mockedFactory.Verify(f => f.CreateMeasurement(height, weightKg, bodyFatPercent, chest, shoulders, forearm, arm, waist, hips, thighs,
                                                          calves, neck, wrist, ankle, userId, date),
                                 Times.Never);
        }
Пример #24
0
        public async Task <IHttpActionResult> CreateMeasurement(CreateMeasurement model)
        {
            //check if model is valid
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            MeasurementService service = CreateMeasurementService();

            if (await service.CreateMeasurement(model) == false)
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Пример #25
0
        public void TestGetByDate_ShouldCallRepositoryAll(string userId)
        {
            // Arrange
            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();
            var mockedUnitOfWork            = new Mock <IUnitOfWork>();
            var mockedFactory = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            service.GetByDate(userId, new DateTime());

            // Assert
            mockedMeasurementRepository.Verify(r => r.All, Times.Once);
        }
Пример #26
0
        public void TestDeleteMeasurement_RepositoryReturnsNull_ShouldNotCallRepositoryDelete(int id, string userId)
        {
            // Arrange
            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();
            var mockedUnitOfWork            = new Mock <IUnitOfWork>();
            var mockedFactory = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            service.DeleteMeasurement(id, userId);

            // Assert
            mockedMeasurementRepository.Verify(r => r.Delete(It.IsAny <Measurement>()), Times.Never);
        }
Пример #27
0
        public void TestDeleteMeasurement_ShouldCallRepositoryGetById(int id, string userId)
        {
            // Arrange
            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();
            var mockedUnitOfWork            = new Mock <IUnitOfWork>();
            var mockedFactory = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            service.DeleteMeasurement(id, userId);

            // Assert
            mockedMeasurementRepository.Verify(r => r.GetById(id), Times.Once);
        }
Пример #28
0
        public void TestDeleteMeasurement_RepositoryReturnsNull_ShouldReturnFalse(int id, string userId)
        {
            // Arrange
            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();
            var mockedUnitOfWork            = new Mock <IUnitOfWork>();
            var mockedFactory = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            var result = service.DeleteMeasurement(id, userId);

            // Assert
            Assert.IsFalse(result);
        }
        public Size Measure(IExportColumn exportColumn, Graphics graphics)
        {
            var items = ((ExportContainer)exportColumn).ExportedItems;

            foreach (var element in items)
            {
                if (element is IExportContainer)
                {
                    Measure(element, graphics);
                }
                var tbi = element as IExportText;
                if (tbi != null)
                {
                    element.DesiredSize = MeasurementService.Measure(tbi, graphics);
                }
            }
            exportColumn.DesiredSize = exportColumn.Size;
            return(exportColumn.DesiredSize);
        }
Пример #30
0
        public void TestCreateMeasurement_ShouldReturnCorrectly(int height,
                                                                double weightKg,
                                                                double bodyFatPercent,
                                                                int chest,
                                                                int shoulders,
                                                                int forearm,
                                                                int arm,
                                                                int waist,
                                                                int hips,
                                                                int thighs,
                                                                int calves,
                                                                int neck,
                                                                int wrist,
                                                                int ankle,
                                                                string userId)
        {
            // Arrange,
            var date = new DateTime(2, 3, 4);

            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();
            var mockedUnitOfWork            = new Mock <IUnitOfWork>();

            var measurement = new Measurement();

            var mockedFactory = new Mock <IMeasurementFactory>();

            mockedFactory.Setup(f => f.CreateMeasurement(It.IsAny <int>(), It.IsAny <double>(), It.IsAny <double>(), It.IsAny <int>(), It.IsAny <int>(),
                                                         It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(),
                                                         It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <DateTime>()))
            .Returns(measurement);

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            var result = service.CreateMeasurement(height, weightKg, bodyFatPercent, chest, shoulders, forearm, arm, waist, hips, thighs,
                                                   calves, neck, wrist, ankle, userId, date);

            // Assert
            Assert.AreSame(measurement, result);
        }
Пример #31
0
        public void TestDeleteMeasurement_RepositoryReturnsMeasurementWithDifferentUserId_ShouldReturnFalse(int id, string userId)
        {
            // Arrange
            var mockedMeasurementRepository = new Mock <IRepository <Measurement> >();

            mockedMeasurementRepository.Setup(r => r.GetById(It.IsAny <object>())).Returns(new Measurement());

            var mockedUnitOfWork = new Mock <IUnitOfWork>();
            var mockedFactory    = new Mock <IMeasurementFactory>();

            var service = new MeasurementService(mockedMeasurementRepository.Object,
                                                 mockedUnitOfWork.Object,
                                                 mockedFactory.Object);

            // Act
            var result = service.DeleteMeasurement(id, userId);

            // Assert
            Assert.IsFalse(result);
        }