コード例 #1
0
ファイル: ProjectObject.cs プロジェクト: AleksMorozova/prizm
 public ProjectObject(Project project)
 {
    this.Id = project.Id;
    this.IsActive = project.IsActive;
    this.Title = project.Title;
    this.Client = project.Client;
    this.MillName = project.MillName;
    this.DocumentSizeLimit = project.DocumentSizeLimit;
    this.WorkstationType = project.WorkstationType;
    this.MillPipeNumberMask = project.MillPipeNumberMask;
    this.MillPipeNumberMaskRegexp = project.MillPipeNumberMaskRegexp;
 }
コード例 #2
0
 public PrizmApplicationViewModel(IProjectRepository repo, IUserNotify notify)
 {
     this.repo = repo;
     this.ProjectSettings = repo.GetSingle();
     this.notify = notify;
 }
コード例 #3
0
        public void TestSaveSettings()
        {
            var notify = new Mock<IUserNotify>();

            var repoPipeSize = new Mock<IMillPipeSizeTypeRepository>();
            var repoPipeTests = new Mock<IPipeTestRepository>();
            var repoWelders = new Mock<IWelderRepository>();
            var repoInspectors = new Mock<IInspectorRepository>();
            var repoManufacturers = new Mock<IPlateManufacturerRepository>();
            var repoProjectSetting = new Mock<IProjectRepository>();
            var repoUsers = new Mock<IUserRepository>();
            var repoRoles = new Mock<IRoleRepository>();
            var repoPerms = new Mock<IPermissionRepository>();
            var repoCategory = new Mock<ICategoryRepository>();
            var repoJointOperation = new Mock<IJointOperationRepository>();
            var repoCertificateType = new Mock<ICertificateTypeRepository>();
            var repoComponentType = new Mock<IComponentTypeRepository>();
            var repoSeamType = new Mock<ISeamTypeRepository>();

            var testProjectSetting = new Project() { IsNative = true};
            var testSizeType = new PipeMillSizeType() 
            { 
                IsNative = true, 
                Project = testProjectSetting,
                Diameter = 10,
                Thickness = 5,
                SeamType = new SeamType(),
                Length = 20,
            };
            foreach (PipeTest t in testSizeType.PipeTests)
            {
                t.Code = "Code";
                t.Name = "Name";
                t.ControlType = PipeTestControlType.Monitor;
                t.ResultType = PipeTestResultType.Boolean;
            }
            var testWelder = new Welder() { Certificate = new Certificate() { ExpirationDate = DateTime.Now} };
            var testManufacturer = new PlateManufacturer() { IsNative = true, Project = testProjectSetting};
            var testInspector = new Inspector();
            var testUser = new User();
            var testRole = new Role();
            var testPerm = new Permission() { Name = "CreateJoint" };
            var modifiableView = new Mock<IModifiable>();
            var jointOperations = new JointOperation();
            var ctx = new Mock<ISecurityContext>();

            repoPipeSize.Setup(_ => _.GetAll()).Returns(new List<PipeMillSizeType>() { testSizeType });
            repoWelders.Setup(_ => _.GetAll()).Returns(new List<Welder>() { testWelder });
            repoManufacturers.Setup(_ => _.GetAll()).Returns(new List<PlateManufacturer>() { testManufacturer });
            repoProjectSetting.Setup(_ => _.GetSingle()).Returns(testProjectSetting);
            repoInspectors.Setup(_ => _.GetAll()).Returns(new List<Inspector>() { testInspector });
            repoUsers.Setup(_ => _.GetAll()).Returns(new List<User>() { testUser });
            repoRoles.Setup(_ => _.GetAll()).Returns(new List<Role>() { testRole });
            repoPerms.Setup(_ => _.GetAll()).Returns(new List<Permission>() { testPerm });
            repoJointOperation.Setup(_ => _.GetAll()).Returns(new List<JointOperation>() { jointOperations });
            repoCategory.Setup(x => x.GetAll()).Returns(new List<Category>() { new Category() });
            repoCertificateType.Setup(x => x.GetAll()).Returns(new List<InspectorCertificateType>() { new InspectorCertificateType() });
            repoComponentType.Setup(x => x.GetAll()).Returns(new List<ComponentType>() { new ComponentType() });


            Mock<ISettingsRepositories> settingsRepos = new Mock<ISettingsRepositories>();
            settingsRepos.SetupGet(_ => _.PipeSizeTypeRepo).Returns(repoPipeSize.Object);
            settingsRepos.SetupGet(_ => _.PipeTestRepo).Returns(repoPipeTests.Object);
            settingsRepos.SetupGet(_ => _.WelderRepo).Returns(repoWelders.Object);
            settingsRepos.SetupGet(_ => _.PlateManufacturerRepo).Returns(repoManufacturers.Object);
            settingsRepos.SetupGet(_ => _.ProjectRepo).Returns(repoProjectSetting.Object);
            settingsRepos.SetupGet(_ => _.InspectorRepo).Returns(repoInspectors.Object);
            settingsRepos.SetupGet(_ => _.UserRepo).Returns(repoUsers.Object);
            settingsRepos.SetupGet(_ => _.RoleRepo).Returns(repoRoles.Object);
            settingsRepos.SetupGet(_ => _.PermissionRepo).Returns(repoPerms.Object);
            settingsRepos.SetupGet(_ => _.JointRepo).Returns(repoJointOperation.Object);
            settingsRepos.SetupGet(x => x.СategoryRepo).Returns(repoCategory.Object);
            settingsRepos.SetupGet(x => x.CertificateTypeRepo).Returns(repoCertificateType.Object);
            settingsRepos.SetupGet(x => x.ComponentTypeRepo).Returns(repoComponentType.Object);
            settingsRepos.SetupGet(x => x.SeamTypeRepo).Returns(repoSeamType.Object);

            var viewModel = new SettingsViewModel(settingsRepos.Object, notify.Object, ctx.Object);
            viewModel.ModifiableView = modifiableView.Object;
            viewModel.LoadData();
            viewModel.ModifiableView = modifiableView.Object;
            var validatable = new Mock<IValidatable>();
            validatable.Setup(x => x.Validate()).Returns(true);
            viewModel.validatableView = validatable.Object;

            var command = new SaveSettingsCommand(viewModel, settingsRepos.Object, notify.Object, ctx.Object);

            command.Execute();

            settingsRepos.Verify(_ => _.BeginTransaction(), Times.Once());
            repoPipeSize.Verify(_ => _.SaveOrUpdate(testSizeType), Times.Once());
            settingsRepos.Verify(_ => _.Commit(), Times.Once());
            repoPipeSize.Verify(_ => _.Evict(testSizeType), Times.Once());
            repoWelders.Verify(_ => _.SaveOrUpdate(testWelder), Times.Once());
            repoWelders.Verify(_ => _.Evict(testWelder), Times.Once());
            repoManufacturers.Verify(_ => _.SaveOrUpdate(testManufacturer), Times.Once());
            repoManufacturers.Verify(_ => _.Evict(testManufacturer), Times.Once());
            repoProjectSetting.Verify(_ => _.SaveOrUpdate(testProjectSetting), Times.Once());
            repoProjectSetting.Verify(_ => _.Evict(testProjectSetting), Times.Once());
            repoInspectors.Verify(_ => _.SaveOrUpdate(testInspector), Times.Once());
            repoInspectors.Verify(_ => _.Evict(testInspector), Times.Once());
            repoUsers.Verify(_ => _.SaveOrUpdate(testUser), Times.Once());
            repoUsers.Verify(_ => _.Evict(testUser), Times.Once());
            repoRoles.Verify(_ => _.SaveOrUpdate(testRole), Times.Once());
            repoRoles.Verify(_ => _.Evict(testRole), Times.Once());
        }
コード例 #4
0
ファイル: DataExporter.cs プロジェクト: AleksMorozova/prizm
        Data PrepareData(Portion portion, Project project)
        {
            Data data = new Data();
            data.Pipes = new List<PipeObject>();
            data.Joints = new List<JointObject>();
            data.Components = new List<ComponentObject>();
            data.Project = project;

            foreach(var pipe in portion.Pipes)
            {
                data.Pipes.Add(new PipeObject(pipe));
            }

            foreach(var joint in portion.Joints)
            {
                data.Joints.Add(new JointObject(joint));
            }

            foreach(var component in portion.Components)
            {
                data.Components.Add(new ComponentObject(component));
            }

            return data;
        }