Exemplo n.º 1
0
        public void AddMaterial_ProblemWithMaterials_ExpectMaterialIdCorrectlyInitialized()
        {
            //Arrange
            var modelProblem = new ModelProblem("problem");

            modelProblem.AddMaterial();
            modelProblem.AddMaterial();
            modelProblem.AddMaterial();

            //Act
            var material = modelProblem.AddMaterial();

            //Assert
            Assert.That(material.Id, Is.EqualTo(4));
        }
Exemplo n.º 2
0
        public void DeleteMaterial_ProblemWithSeveralMaterials_ExpectMaterialIdsAreCorrect()
        {
            //Arrange
            var modelProblem = new ModelProblem("problem");

            var material1 = modelProblem.AddMaterial();
            var material2 = modelProblem.AddMaterial();
            var material3 = modelProblem.AddMaterial();
            var material4 = modelProblem.AddMaterial();
            var material5 = modelProblem.AddMaterial();

            //Act
            modelProblem.DeleteMaterial(material1);

            //Assert
            Assert.AreEqual(material2.Id, 1);
            Assert.AreEqual(material3.Id, 2);
            Assert.AreEqual(material4.Id, 3);
            Assert.AreEqual(material5.Id, 4);
        }
Exemplo n.º 3
0
        public void AddMaterial_EmptyProblem_ExpectMaterialAddedToCollection()
        {
            //Arrange
            var modelProblem = new ModelProblem("problem");

            //Act
            var material = modelProblem.AddMaterial();

            //Assert
            Assert.That(modelProblem.Materials.Contains(material), Is.True);
        }
Exemplo n.º 4
0
        private static IModelProblem BuildProblem(ProblemMemento problemMemento)
        {
            var modelProblem = new ModelProblem(problemMemento.Name);

            Dictionary <int, IModelNode>     nodesDictionary     = new Dictionary <int, IModelNode>();
            Dictionary <int, IModelMaterial> materialsDictionary = new Dictionary <int, IModelMaterial>();

            foreach (var nodeMemento in problemMemento.Nodes.OrderBy(x => x.Id))
            {
                var modelNode = modelProblem.AddNode();

                modelNode.IsXFixed      = nodeMemento.IsXFixed;
                modelNode.IsYFixed      = nodeMemento.IsYFixed;
                modelNode.IsZFixed      = nodeMemento.IsZFixed;
                modelNode.Coordinates.X = nodeMemento.X;
                modelNode.Coordinates.Y = nodeMemento.Y;
                modelNode.Coordinates.Z = nodeMemento.Z;

                nodesDictionary.Add(nodeMemento.Id, modelNode);
            }

            foreach (var forceMemento in problemMemento.Forces.OrderBy(x => x.Id))
            {
                var applicationNode = nodesDictionary[forceMemento.NodeId];

                var modelForce = modelProblem.AddForce(applicationNode);
                modelForce.ApplicationVector.X = forceMemento.ApplicationVectorX;
                modelForce.ApplicationVector.Y = forceMemento.ApplicationVectorY;
                modelForce.ApplicationVector.Z = forceMemento.ApplicationVectorZ;
            }

            foreach (var mementoMaterial in problemMemento.Materials.OrderBy(x => x.Id))
            {
                var modelMaterial = modelProblem.AddMaterial();

                modelMaterial.Name          = mementoMaterial.Name;
                modelMaterial.YoungsModulus = mementoMaterial.YoungsModulus;

                materialsDictionary.Add(mementoMaterial.Id, modelMaterial);
            }

            foreach (var elementMemento in problemMemento.Elements.OrderBy(x => x.Id))
            {
                var modelMaterial        = materialsDictionary[elementMemento.MaterialId];
                var originModelNode      = nodesDictionary[elementMemento.OriginNodeId];
                var destinationModelNode = nodesDictionary[elementMemento.DestinationNodeId];

                var modelElement = modelProblem.AddElement(originModelNode, destinationModelNode);
                modelElement.Material         = modelMaterial;
                modelElement.CrossSectionArea = elementMemento.CrossSectionArea;
            }

            return(modelProblem);
        }
Exemplo n.º 5
0
        public void DeleteMaterial_MaterialDoesExistInProblem_ExpectMaterialRemovedFromCollection()
        {
            //Arrange
            var modelProblem = new ModelProblem("problem");

            var material = modelProblem.AddMaterial();

            //Act
            modelProblem.DeleteMaterial(material);

            //Assert
            Assert.That(modelProblem.Materials, Is.Empty);
        }
Exemplo n.º 6
0
        public void ValidateElement_SetStraMaterial_ExpectInvalidOperationException()
        {
            //Arrange
            ModelProblem problem = new ModelProblem("problem");

            var node1   = problem.AddNode();
            var node2   = problem.AddNode();
            var element = problem.AddElement(node1, node2);

            var otherProblem = new ModelProblem("otherProblem");
            var material     = otherProblem.AddMaterial();

            //Act
            //Assert
            Assert.Throws <InvalidOperationException>(() => element.Material = material);
        }
Exemplo n.º 7
0
        public (NodeViewModel, NodeViewModel, MaterialViewModel, MaterialViewModel, IModelElement) BuildTestElementWithAdditionalMaterial()
        {
            var modelProblem = new ModelProblem("test");

            var node1 = modelProblem.AddNode();
            var node2 = modelProblem.AddNode();

            var element = modelProblem.AddElement(node1, node2);

            var nodeViewModel1 = new NodeViewModel(node1);
            var nodeViewModel2 = new NodeViewModel(node2);

            var otherMaterial = modelProblem.AddMaterial();

            var materialViewModel1 = new MaterialViewModel(element.Material);
            var materialViewModel2 = new MaterialViewModel(otherMaterial);

            return(nodeViewModel1, nodeViewModel2, materialViewModel1, materialViewModel2, element);
        }
        private static IModelMaterial BuildModelMaterial()
        {
            var modelProblem = new ModelProblem("test");

            return(modelProblem.AddMaterial());
        }