public void Node_NodeChangedAndRelevantPropertyOfNewNodeChanged_ExpectPropertiesChangedEventRaised() { //Arrange var modelProblem = new ModelProblem("test"); var node1 = modelProblem.AddNode(); var node2 = modelProblem.AddNode(); var modelForce = modelProblem.AddForce(node1); var nodeViewModel1 = new NodeViewModel(node1); var nodeViewModel2 = new NodeViewModel(node2); var forceViewModel = new ForceViewModel(modelForce, nodeViewModel1); forceViewModel.Node = nodeViewModel2; var eventChecker = new PropertyChangedEventChecker(forceViewModel); //Act nodeViewModel2.X = 123; //Assert Assert.That(eventChecker.PropertiesRaised, Is.EqualTo(new[] { "Node", "ResultGeometry" })); }
private static IModelNode BuildTestNode() { var modelProblem = new ModelProblem("test"); var node = modelProblem.AddNode(); return(node); }
public void AddForce_NullNode_ExpectArgumentNullException() { //Arrange var modelProblem = new ModelProblem("problem"); //Act //Assert Assert.Throws <ArgumentNullException>(() => modelProblem.AddForce(null)); }
private static IModelElement BuildElement() { var modelProblem = new ModelProblem("test"); var node1 = modelProblem.AddNode(); var node2 = modelProblem.AddNode(); return(modelProblem.AddElement(node1, node2)); }
public void DeleteMaterial_NullMaterial_ExpectArgumentNullException() { //Arrange var modelProblem = new ModelProblem("problem"); //Act //Assert Assert.Throws <ArgumentNullException>(() => modelProblem.DeleteMaterial(null)); }
public void AddNode_EmptyProblem_ExpectNodeIdCorrectlyInitialized() { //Arrange var modelProblem = new ModelProblem("problem"); //Act var node = modelProblem.AddNode(); //Assert Assert.That(node.Id, Is.EqualTo(1)); }
public void AddMaterial_EmptyProblem_ExpectMaterialIdCorrectlyInitialized() { //Arrange var modelProblem = new ModelProblem("problem"); //Act var material = modelProblem.AddMaterial(); //Assert Assert.That(material.Id, Is.EqualTo(1)); }
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); }
public void DeleteMaterial_MaterialIsUsedByElement_ExpectInvalidOperationException() { //Arrange var modelProblem = new ModelProblem("problem"); var element = modelProblem.AddElement(modelProblem.AddNode(), modelProblem.AddNode()); //Act //Assert Assert.Throws <InvalidOperationException>(() => modelProblem.DeleteMaterial(element.Material)); }
public void AddForce_InvalidOriginNode_ExpectInvalidOperationException() { //Arrange var modelProblem = new ModelProblem("problem"); var node = new ModelNode(new ModelProblem("otherProblem"), 123); //Act //Assert Assert.Throws <InvalidOperationException>(() => modelProblem.AddForce(node)); }
public void AddNode_EmptyProblem_ExpectNodeAddedToCollection() { //Arrange var modelProblem = new ModelProblem("problem"); //Act var node = modelProblem.AddNode(); //Assert Assert.That(modelProblem.Nodes.Contains(node), Is.True); }
public void AddElement_NullDestinationNode_ExpectArgumentNullException() { //Arrange var modelProblem = new ModelProblem("problem"); var node = modelProblem.AddNode(); //Act //Assert Assert.Throws <ArgumentNullException>(() => modelProblem.AddElement(node, null)); }
public void AddElement_BothNodesAreTheSame_ExpectInvalidOperationException() { //Arrange var modelProblem = new ModelProblem("problem"); var origin = modelProblem.AddNode(); //Act //Assert Assert.Throws <InvalidOperationException>(() => modelProblem.AddElement(origin, origin)); }
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); }
public void SerializeProblem_NullFilePath_ThrowsArgumentException() { //Arrange var filesystem = new FakeFileSystem(); var problemSerializer = new ProblemSerializer(filesystem); var modelProblem = new ModelProblem("test"); //Act //Assert Assert.Throws <ArgumentException>(() => problemSerializer.SerializeProblem(modelProblem, null)); }
private static (NodeViewModel, IModelForce) BuildTestForce() { var modelProblem = new ModelProblem("test"); var node = modelProblem.AddNode(); var force = modelProblem.AddForce(node); var nodeViewModel = new NodeViewModel(node); return(nodeViewModel, force); }
public void Ctor_ExpectPropertiesCorrectlyInitialized() { //Arrange //Act var modelProblem = new ModelProblem("problem name"); //Assert Assert.That(modelProblem.Name, Is.EqualTo("problem name")); Assert.That(modelProblem.Nodes, Is.Empty); Assert.That(modelProblem.Elements, Is.Empty); Assert.That(modelProblem.Forces, Is.Empty); }
public void DeleteNode_NodeIsUsedByElementInDestinationNode_ExpectInvalidOperationException() { //Arrange var modelProblem = new ModelProblem("problem"); var node = modelProblem.AddNode(); var element = modelProblem.AddElement(modelProblem.AddNode(), node); //Act //Assert Assert.Throws <InvalidOperationException>(() => modelProblem.DeleteNode(node)); }
public void AddElement_InvalidOriginNode_ExpectInvalidOperationException() { //Arrange var modelProblem = new ModelProblem("problem"); var origin = new ModelNode(new ModelProblem("otherProblem"), 123); var destination = modelProblem.AddNode(); //Act //Assert Assert.Throws <InvalidOperationException>(() => modelProblem.AddElement(origin, destination)); }
public void DeleteNode_NodeDoesNotExistInProblem_ExpectNothingHappens() { //Arrange var modelProblem = new ModelProblem("problem"); var strayNode = new ModelNode(new ModelProblem("otherProblem"), 666); //Act modelProblem.DeleteNode(strayNode); //Assert Assert.That(modelProblem.Nodes, Is.Empty); }
public void AddForce_ForceWithSameNodeAlreadyExists_ExpectInvalidOperationException() { //Arrange var modelProblem = new ModelProblem("problem"); var node = modelProblem.AddNode(); modelProblem.AddForce(node); //Act //Assert Assert.Throws <InvalidOperationException>(() => modelProblem.AddForce(node)); }
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); }
public void DeleteNode_NodeDoesExistInProblem_ExpectNodeRemovedFromCollection() { //Arrange var modelProblem = new ModelProblem("problem"); var node = modelProblem.AddNode(); //Act modelProblem.DeleteNode(node); //Assert Assert.That(modelProblem.Nodes, Is.Empty); }
public void DeleteForce_ForceDoesExistInProblem_ExpectForceRemovedFromCollection() { //Arrange var modelProblem = new ModelProblem("problem"); var force = modelProblem.AddForce(modelProblem.AddNode()); //Act modelProblem.DeleteForce(force); //Assert Assert.That(modelProblem.Forces, Is.Empty); }
public void ValidateElements_MakeElementHaveSameNodeAsDestinationAndOrigin_ExpectInvalidOperationException() { //Arrange ModelProblem problem = new ModelProblem("problem"); var node1 = problem.AddNode(); var node2 = problem.AddNode(); var element = problem.AddElement(node1, node2); //Act //Assert Assert.Throws <InvalidOperationException>(() => element.OriginNode = node2); }
public void AddElement_EmptyProblem_ExpectElementMaterialAddedToCollection() { //Arrange var modelProblem = new ModelProblem("problem"); var origin = modelProblem.AddNode(); var destination = modelProblem.AddNode(); //Act var element = modelProblem.AddElement(origin, destination); //Assert Assert.That(modelProblem.Materials.Contains(element.Material), Is.True); }
public void AddElement_EmptyProblem_ExpectElementIdCorrectlyInitialized() { //Arrange var modelProblem = new ModelProblem("problem"); var origin = modelProblem.AddNode(); var destination = modelProblem.AddNode(); //Act var element = modelProblem.AddElement(origin, destination); //Assert Assert.That(element.Id, Is.EqualTo(1)); }
public void DeleteMaterial_MaterialDoesNotExistInProblem_ExpectNothingHappens() { //Arrange var modelProblem = new ModelProblem("problem"); var otherProblem = new ModelProblem("otherProblem"); var strayMaterial = new ModelMaterial(otherProblem, 666, "strayMaterial", 1); //Act modelProblem.DeleteMaterial(strayMaterial); //Assert Assert.That(modelProblem.Materials, Is.Empty); }
public void DeleteForce_ForceDoesNotExistInProblem_ExpectNothingHappens() { //Arrange var modelProblem = new ModelProblem("problem"); var otherProblem = new ModelProblem("otherProblem"); var strayForce = new ModelForce(otherProblem, 345, new ModelNode(otherProblem, 1234)); //Act modelProblem.DeleteForce(strayForce); //Assert Assert.That(modelProblem.Forces, Is.Empty); }
public void DeleteElement_ElementDoesNotExistInProblem_ExpectNothingHappens() { //Arrange var modelProblem = new ModelProblem("problem"); var otherProblem = new ModelProblem("otherProblem"); var strayElement = new ModelBarElement(otherProblem, 1234, new ModelNode(otherProblem, 123), new ModelNode(otherProblem, 1234)); //Act modelProblem.DeleteElement(strayElement); //Assert Assert.That(modelProblem.Elements, Is.Empty); }