Esempio n. 1
0
        public void CanCreateProjectAndGetDeviceVersion()
        {
            using (var dbFactory = new TestDbConnectionFactory())
                using (var conn = dbFactory.Database())
                {
                    var project = new Project {
                        Name = "Test"
                    };
                    var device = new Device {
                        IpAddress = "192.168.1.1", Name = "MyTestDevice"
                    };

                    project = ProjectActions.CreateProject(project).Function(conn);
                    var projectDevice = DeviceActions.AddDeviceToProject(project.Id, device).Function(conn);

                    var projectDeviceVersion = ProjectDeviceActions.GetLatestProjectDeviceVersion(projectDevice.Id).Function(conn);

                    projectDeviceVersion = ProjectDeviceActions.SetLatestProjectDeviceVersion(new ProjectDeviceVersion
                    {
                        ProjectDeviceId             = projectDevice.Id,
                        HorizontalPercentage        = 100,
                        VerticalPercentage          = 100,
                        NumberOfHorizontalPixels    = 50,
                        NumberOfVerticalPixels      = 50,
                        StartAtHorizontalPercentage = 0,
                        StartAtVerticalPercentage   = 0
                    }).Function(conn);

                    projectDeviceVersion = ProjectDeviceActions.GetLatestProjectDeviceVersion(projectDevice.Id).Function(conn);

                    Assert.NotNull(projectDeviceVersion);
                }
        }
        public void CanDistinguishBetweenProjectDevicesAndNonProjectDevices()
        {
            using (var dbFactory = new TestDbConnectionFactory())
                using (var conn = dbFactory.Database())
                {
                    var project = new Project {
                        Name = "Test"
                    };
                    var anotherProject = new Project {
                        Name = "Test2"
                    };
                    var device = new Device {
                        IpAddress = "192.168.1.1", Name = "MyTestDevice"
                    };
                    var anotherDevice = new Device {
                        IpAddress = "192.168.1.2", Name = "MyOtherTestDevice"
                    };

                    project        = ProjectActions.CreateProject(project).Function(conn);
                    anotherProject = ProjectActions.CreateProject(anotherProject).Function(conn);
                    var projectDevice        = DeviceActions.AddDeviceToProject(project.Id, device).Function(conn);
                    var anotherProjectDevice = DeviceActions.AddDeviceToProject(anotherProject.Id, anotherDevice).Function(conn);

                    var devices = DeviceActions.GetProjectDevices(project.Id).Function(conn);

                    Assert.Equal(1, devices.Count());

                    var retrievedDevice = devices.Single();

                    Assert.Equal(device.IpAddress, retrievedDevice.IpAddress);
                    Assert.Equal(device.Name, retrievedDevice.Name);
                }
        }
Esempio n. 3
0
        public void CanSetProjectDeviceMappingsTwice()
        {
            using (var dbFactory = new TestDbConnectionFactory())
                using (var conn = dbFactory.Database())
                {
                    var project = new Project {
                        Name = "Test"
                    };
                    var device = new Device {
                        IpAddress = "192.168.1.1", Name = "MyTestDevice"
                    };

                    project = ProjectActions.CreateProject(project).Function(conn);
                    var projectDevice        = DeviceActions.AddDeviceToProject(project.Id, device).Function(conn);
                    var projectDeviceVersion = ProjectDeviceActions.SetLatestProjectDeviceVersion(new ProjectDeviceVersion
                    {
                        ProjectDeviceId             = projectDevice.Id,
                        HorizontalPercentage        = 100,
                        VerticalPercentage          = 100,
                        NumberOfHorizontalPixels    = 50,
                        NumberOfVerticalPixels      = 50,
                        StartAtHorizontalPercentage = 0,
                        StartAtVerticalPercentage   = 0
                    }).Function(conn);

                    var firstMappings = new List <ProjectDeviceVersionMapping>
                    {
                        new ProjectDeviceVersionMapping
                        {
                            HorizontalPosition = 1,
                            VerticalPosition   = 1,
                            MappingOrder       = 1
                        }
                    };

                    var secondMappings = new List <ProjectDeviceVersionMapping>
                    {
                        new ProjectDeviceVersionMapping
                        {
                            HorizontalPosition = 1,
                            VerticalPosition   = 1,
                            MappingOrder       = 1,
                        },
                        new ProjectDeviceVersionMapping
                        {
                            HorizontalPosition = 2,
                            VerticalPosition   = 1,
                            MappingOrder       = 2
                        }
                    };

                    ProjectDeviceActions.SetProjectDeviceMappings(projectDeviceVersion.Id, firstMappings).Function(conn);
                    ProjectDeviceActions.SetProjectDeviceMappings(projectDeviceVersion.Id, secondMappings).Function(conn);

                    var result = ProjectDeviceActions.GetProjectDeviceMappings(projectDeviceVersion.Id).Function(conn);

                    Assert.Equal(2, result.Count());
                }
        }
 public void CanCreateProject()
 {
     using (var dbFactory = new TestDbConnectionFactory())
         using (var conn = dbFactory.Database())
         {
             ProjectActions
             .CreateProject(new Project {
                 Id = 1, Name = "Test"
             })
             .Function(conn);
         }
 }
        public void CanAddDeviceToProject()
        {
            using (var dbFactory = new TestDbConnectionFactory())
                using (var conn = dbFactory.Database())
                {
                    var project = new Project {
                        Name = "Test"
                    };
                    var device = new Device {
                        IpAddress = "192.168.1.1", Name = "MyTestDevice"
                    };

                    project = ProjectActions.CreateProject(project).Function(conn);
                    DeviceActions.AddDeviceToProject(project.Id, device).Function(conn);
                }
        }
        public void CanGetAllProjects()
        {
            using (var dbFactory = new TestDbConnectionFactory())
                using (var conn = dbFactory.Database())
                {
                    var project = new Project {
                        Id = 1, Name = "Test"
                    };

                    ProjectActions
                    .CreateProject(project)
                    .Function(conn);

                    ProjectActions
                    .GetAllProjects()
                    .Function(conn);
                }
        }
Esempio n. 7
0
        public void CanUndoProjectDeviceVersion()
        {
            using (var dbFactory = new TestDbConnectionFactory())
                using (var conn = dbFactory.Database())
                {
                    var project = new Project {
                        Name = "Test"
                    };
                    var device = new Device {
                        IpAddress = "192.168.1.1", Name = "MyTestDevice"
                    };

                    project = ProjectActions.CreateProject(project).Function(conn);
                    var projectDevice = DeviceActions.AddDeviceToProject(project.Id, device).Function(conn);

                    var projectDeviceVersion = ProjectDeviceActions.SetLatestProjectDeviceVersion(new ProjectDeviceVersion
                    {
                        ProjectDeviceId             = projectDevice.Id,
                        HorizontalPercentage        = 100,
                        VerticalPercentage          = 100,
                        NumberOfHorizontalPixels    = 50,
                        NumberOfVerticalPixels      = 50,
                        StartAtHorizontalPercentage = 0,
                        StartAtVerticalPercentage   = 0
                    }).Function(conn);

                    var updatedProjectDeviceVersion = ProjectDeviceActions.SetLatestProjectDeviceVersion(new ProjectDeviceVersion
                    {
                        ProjectDeviceId             = projectDevice.Id,
                        HorizontalPercentage        = 99,
                        VerticalPercentage          = 99,
                        NumberOfHorizontalPixels    = 30,
                        NumberOfVerticalPixels      = 30,
                        StartAtHorizontalPercentage = 1,
                        StartAtVerticalPercentage   = 1
                    }).Function(conn);

                    var undoneProjectDeviceVersion = ProjectDeviceActions.UndoLatestProjectDeviceVersion(projectDevice.Id).Function(conn);

                    var undoEqualsOriginalProjectDeviceVersion = projectDeviceVersion.PropertiesAreEqual(undoneProjectDeviceVersion);

                    Assert.True(undoEqualsOriginalProjectDeviceVersion);
                }
        }
        public void CanDeleteProject()
        {
            using (var dbFactory = new TestDbConnectionFactory())
                using (var conn = dbFactory.Database())
                {
                    var project = new Project {
                        Id = 1, Name = "Test"
                    };

                    ProjectActions
                    .CreateProject(project)
                    .Function(conn);

                    ProjectActions
                    .DeleteProject(project.Id)
                    .Action(conn);

                    var get = ProjectActions
                              .GetProject(project.Id)
                              .Function(conn);

                    Assert.Null(get);
                }
        }
        public GlobalJsonResult <Project> Create([FromBody] Project project)
        {
            dispatcher.Dispatch(ProjectActions.CreateProject(project));

            return(GlobalJsonResult <Project> .Success(System.Net.HttpStatusCode.Created, project));
        }