コード例 #1
0
 private bool IsComponentsConnected(Prizm.Domain.Entity.Construction.Component component)
 {
     return
         (component
          .Connectors
          .Any <Connector>(x => x.Joint != null && x.Joint.Id != Guid.Empty));
 }
コード例 #2
0
      public ComponentObject(Component component)
      {
         this.Id = component.Id;
         this.IsActive = component.IsActive;
         this.Certificate = component.Certificate;
         this.Type = component.Type;
         this.Number = component.Number;
         this.Length = component.Length;
         this.IsAvailableToJoint = component.IsAvailableToJoint;
         this.ConstructionStatus = component.ConstructionStatus;
         this.InspectionStatus = component.InspectionStatus;

         if (component.Connectors != null)
         {
             this.Connectors = new List<ConnectorObject>();
             foreach (var connector in component.Connectors)
             {
                this.Connectors.Add(new ConnectorObject(connector));
             }
         }

          if (component.Attachments != null)
         {
            this.Attachments = new List<FileObject>();
            foreach (var file in component.Attachments)
            {
               Attachments.Add(new FileObject(file));
            }
         }
      }
コード例 #3
0
        public void TestNewSaveComponent()
        {
            var modifiableView  = new Mock <IModifiable>();
            var validatableView = new Mock <IValidatable>();
            var notify          = new Mock <IUserNotify>();
            var securityContext = new Mock <ISecurityContext>();


            var componentRepo     = new Mock <IComponentRepository>();
            var componentTypeRepo = new Mock <IComponentTypeRepository>();
            var repoInspector     = new Mock <IInspectorRepository>();

            var component = new Prizm.Domain.Entity.Construction.Component()
            {
                Number = string.Empty
            };

            componentRepo.Setup(x => x.GetActiveByNumber(component)).Returns(new List <Prizm.Domain.Entity.Construction.Component>());
            componentTypeRepo.Setup(x => x.GetAll()).Returns(new List <ComponentType>());
            componentTypeRepo.Setup(x => x.GetAll()).Returns(new List <ComponentType>());

            var componentsRepos = new Mock <IComponentRepositories>();

            componentsRepos.SetupGet(_ => _.ComponentRepo).Returns(componentRepo.Object);
            componentsRepos.SetupGet(_ => _.ComponentTypeRepo).Returns(componentTypeRepo.Object);
            componentsRepos.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object);


            modifiableView.SetupGet(x => x.IsModified).Returns(false);

            validatableView.Setup(t => t.Validate()).Returns(true);



            var viewModel = new ComponentNewEditViewModel(
                componentsRepos.Object,
                Guid.Empty,
                notify.Object,
                securityContext.Object);

            viewModel.Component       = component;
            viewModel.ModifiableView  = modifiableView.Object;
            viewModel.ValidatableView = validatableView.Object;

            var command = new NewSaveComponentCommand(
                viewModel,
                componentsRepos.Object,
                notify.Object,
                securityContext.Object);

            command.Execute();

            componentsRepos.Verify(_ => _.BeginTransaction(), Times.Once());
            componentRepo.Verify(_ => _.SaveOrUpdate(It.IsAny <Prizm.Domain.Entity.Construction.Component>()), Times.Once());
            componentsRepos.Verify(_ => _.Commit(), Times.Once());
            componentRepo.Verify(_ => _.Evict(It.IsAny <Prizm.Domain.Entity.Construction.Component>()), Times.Once());
        }
コード例 #4
0
        public void TestNewSaveComponent()
        {
            var modifiableView = new Mock<IModifiable>();
            var validatableView = new Mock<IValidatable>();
            var notify = new Mock<IUserNotify>();
            var securityContext = new Mock<ISecurityContext>();


            var componentRepo = new Mock<IComponentRepository>();
            var componentTypeRepo = new Mock<IComponentTypeRepository>();
            var repoInspector = new Mock<IInspectorRepository>();

            var component = new Prizm.Domain.Entity.Construction.Component() { Number = string.Empty};

            componentRepo.Setup(x => x.GetActiveByNumber(component)).Returns(new List<Prizm.Domain.Entity.Construction.Component>());
            componentTypeRepo.Setup(x => x.GetAll()).Returns(new List<ComponentType>());
            componentTypeRepo.Setup(x => x.GetAll()).Returns(new List<ComponentType>());

            var componentsRepos = new Mock<IComponentRepositories>();

            componentsRepos.SetupGet(_ => _.ComponentRepo).Returns(componentRepo.Object);
            componentsRepos.SetupGet(_ => _.ComponentTypeRepo).Returns(componentTypeRepo.Object);
            componentsRepos.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object);


            modifiableView.SetupGet(x => x.IsModified).Returns(false);

            validatableView.Setup(t => t.Validate()).Returns(true);



            var viewModel = new ComponentNewEditViewModel(
                componentsRepos.Object,
                Guid.Empty,
                notify.Object,
                securityContext.Object);

            viewModel.Component = component;
            viewModel.ModifiableView = modifiableView.Object;
            viewModel.ValidatableView = validatableView.Object;

            var command = new NewSaveComponentCommand(
                viewModel,
                componentsRepos.Object,
                notify.Object,
                securityContext.Object);

            command.Execute();

            componentsRepos.Verify(_ => _.BeginTransaction(), Times.Once());
            componentRepo.Verify(_ => _.SaveOrUpdate(It.IsAny<Prizm.Domain.Entity.Construction.Component>()), Times.Once());
            componentsRepos.Verify(_ => _.Commit(), Times.Once());
            componentRepo.Verify(_ => _.Evict(It.IsAny<Prizm.Domain.Entity.Construction.Component>()), Times.Once());
        }