Example #1
0
 public void AddMeasurement(Site site, Measurement measurement)
 {
     repomeasurement_.Add(measurement);
     site.Measurements.Add(measurement);
     repomeasurement_.CommitChanges();
     reposite_.CommitChanges();
 }
Example #2
0
 public Measurement CreateMeasurement(double Value, string Unit)
 {
     Measurement measurement = new Measurement();
     measurement.Value = Value;
     measurement.MeasurementTyp = this.GetMeasurementTyp(Unit);
     measurement.Time = DateTime.Now;
     return measurerepo_.Add(measurement);
 }
Example #3
0
        public void GetLatestSiteStateTest()
        {
            SiteService target = new SiteService(new RepositoryMock<Site>(), new RepositoryMock<Measurement>());
            Site site = new Site()
            {
                Description = "Description",
                Latitude = 43.012312,
                Longitude = 12.12312,
                Serialnumber = "!§$%&/()",
                SiteID = 1
            };
            Measurement expected = new Measurement()
            {
                MeasurementID = 1,
                Time = DateTime.Now,
                Value = 100
            };
            site.Measurements.Add(expected);
            site.Measurements.Add(new Measurement()
            {
                MeasurementID = 2,
                Time = DateTime.Now.Subtract(TimeSpan.FromDays(1000)),
                Value = 100
            });

            site.Measurements.Add(new Measurement()
            {
                MeasurementID = 3,
                Time = DateTime.Now.Subtract(TimeSpan.FromHours(1)),
                Value = 100
            });

            site.Measurements.Add(new Measurement()
            {
                MeasurementID = 4,
                Time = DateTime.Now.Subtract(TimeSpan.FromSeconds(1)),
                Value = 100
            });

            Measurement actual;
            actual = target.GetLatestSiteState(site);
            Assert.AreEqual(expected, actual);
        }
Example #4
0
 public void AddMeasurement(int SiteID, Measurement measurement)
 {
     Site site = reposite_.GetObjectByID(SiteID);
     site.Measurements.Add(measurement);
     reposite_.CommitChanges();
 }
        public void GetCustomerStatisticsExceptionTest()
        {
            IRepository<Measurement> measurerepo = new RepositoryMock<Measurement>();
            
            DateTime StartDate = DateTime.Now.Subtract(TimeSpan.FromDays(1000)); ;
            DateTime EndDate = StartDate.AddDays(100);
            Customer customer = new Customer()
            {
                Person = new Person()
                {
                    Email = "*****@*****.**",
                    Firstname = "PersonVorname",
                    Lastname = "PersonNachname",
                    Password = "******",
                    Username = "******"
                }
            };
            StatisticsService target = new StatisticsService(measurerepo);
            Site site = new Site()
            {
                Description = "Description",
                Latitude = 43.012312,
                Longitude = 12.12312,
                Serialnumber = "!§$%&/()",
                SiteID = 1
            };

            Measurement exp1 = new Measurement()
            {
                MeasurementID = 2,
                Time = StartDate.AddDays(11),
                Value = 100,
                Site = site
            };

            Measurement exp2 = new Measurement()
            {
                MeasurementID = 4,
                Time = StartDate.AddDays(25),
                Value = 100,
                Site = site
            };

            
            
            Measurement somemeasure1 = new Measurement()
            {
                MeasurementID = 1,
                Time = StartDate.Subtract(TimeSpan.FromDays(1)),
                Value = 100,
                Site = site
            };
            site.Measurements.Add(somemeasure1);

            Measurement somemeasure2 = new Measurement()
            {
                MeasurementID = 3,
                Time = EndDate.AddDays(1),
                Value = 100,
                Site = site
            };

            site.Measurements.Add(somemeasure2);
            site.Customer = customer;

            customer.Sites.Add(site);

            measurerepo.Add(somemeasure1);
            measurerepo.Add(somemeasure2);
            measurerepo.Add(exp1);
            measurerepo.Add(exp2);
            List<Measurement> expected =  new List<Measurement>(){ exp1, exp2};
            List<Measurement> actual;
            actual = target.GetCustomerStatistics(customer, StartDate, EndDate);
            CollectionAssert.AreEqual(actual, expected);
        }
Example #6
0
 public void AddMeasurement(int SiteID, Measurement measurement)
 {
 }