示例#1
0
        public void AddSite(Customer custom, string description, double longitude, double latitude)
        {
            IUnityContainer unitycontainer = new UnityContainer();
            unitycontainer.LoadConfiguration("UnityContainer");

            SKS.Scada.BL.ISiteService siteserv = unitycontainer.Resolve<SKS.Scada.BL.ISiteService>();
            siteserv.AddSite(custom, description, longitude, latitude);
        }
示例#2
0
 public Site AddSite(Customer custom, string description, double longitude, double latitude)
 {
     Site site = new Site();
     site.Customer = custom;
     site.Description = description;
     site.Longitude = longitude;
     site.Latitude = latitude;
     site = reposite_.Add(site);
     reposite_.CommitChanges();
     return site;
 }
示例#3
0
 public List<Site> GetSites(Customer customer)
 {
     Validator<Customer> validator = valFactory.CreateValidator<Customer>();
     ValidationResults valResults = validator.Validate(customer);
     if (!valResults.IsValid)
     {
         logger_.Error("Validation Error");
         throw new ValidationException();
     }
     logger_.Info("Returned customers site");
     return customer.Sites.ToList();
 }
示例#4
0
        public List<Measurement> GetCustomerStatistics(Customer customer, DateTime StartDate, DateTime EndDate)
        {
            Validator<Customer> validator = valFactory.CreateValidator<Customer>();
            ValidationResults valResults = validator.Validate(customer);
            if (!valResults.IsValid)
            {
                logger_.Error("Validation Error");
                throw new ValidationException();
            }

            return measurerepo_.GetAll().Where(x => x.Site.Customer == customer && x.Time >= StartDate
                && x.Time <= EndDate ).ToList();
        }
示例#5
0
 public Customer AddCustomer(string firstname, string email, string lastname, string password, string username, Technician technician)
 {
     Customer customer = new Customer();
     customer.Person = new Person()
     {
         Firstname = firstname,
         Email = email,
         Lastname = lastname,
         Password = password,
         Username = username
     };
     customer.Technician = technician;
     customer = repocustomer_.Add(customer);
     repocustomer_.CommitChanges();
     return customer;
 }
        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);
        }
示例#7
0
        public void GetCustomersTest()
        {
            Technician technician = new Technician(); 
            technician.TechnicianID = 1;
            technician.Person = new Person()
            {
                Email = "*****@*****.**",
                Firstname = "PersonVorname",
                Lastname = "PersonNachname",
                Password = "******",
                Username = "******"
            };

            Customer cus = new Customer()
                {
                    Person = new Person()
                        {
                            Email = "*****@*****.**",
                            Firstname = "PersonVorname",
                            Lastname = "PersonNachname",
                            Password = "******",
                            Username = "******"
                        }
                };
            technician.Customers.Add(cus);

            CustomerService target = new CustomerService();

            List<Customer> expected = new List<Customer>(technician.Customers) ; 
            List<Customer> actual;
            actual = target.GetCustomers(technician);
            Assert.AreEqual(expected[0], actual[0]);
            
        }
示例#8
0
        public void GetSitesTest()
        {
            SiteService target = new SiteService(new RepositoryMock<Site>(), new RepositoryMock<Measurement>());
            Customer customer = new Customer()
            {
                Person = new Person()
                {
                    Email = "*****@*****.**",
                    Firstname = "PersonVorname",
                    Lastname = "PersonNachname",
                    Password = "******",
                    Username = "******"
                }
            };

            customer.Sites.Add(new Site()
            {
                Description = "Description",
                Latitude = 43.012312,
                Longitude = 12.12312,
                Serialnumber = "!§$%&/()",
                SiteID = 1
            });

            customer.Sites.Add(new Site()
            {
                Description = "Description",
                Latitude = 43.012312,
                Longitude = 12.12312,
                Serialnumber = "!§$%&/()",
                SiteID = 2
            });

            List<Site> expected = new List<Site>(customer.Sites);
            List<Site> actual;
            actual = target.GetSites(customer);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
        }