private static void AssertSubSection(FailureMechanismSectionAssemblyGroup?subSectionGroup, string subSectionCode, ExportableFailureMechanismType failureMechanismType, ExportableFailureMechanismCombinedSectionAssemblyResult actualResult) { Assert.AreEqual(subSectionGroup, actualResult.SectionAssemblyResult.AssemblyGroup); Assert.AreEqual(subSectionCode, actualResult.Code); Assert.AreEqual(failureMechanismType, actualResult.FailureMechanismType); }
private static void AssertCombinedFailureMechanismSectionAssemblyResult(ExportableFailureMechanismCombinedSectionAssemblyResult expectedSectionResult, SerializableCombinedFailureMechanismSectionAssemblyResult actualSectionResult) { Assert.AreEqual(expectedSectionResult.Code, actualSectionResult.GenericFailureMechanismCode); ExportableFailureMechanismSubSectionAssemblyResult expectedSectionAssemblyResult = expectedSectionResult.SectionAssemblyResult; Assert.AreEqual(SerializableFailureMechanismSectionAssemblyGroupCreator.Create(expectedSectionAssemblyResult.AssemblyGroup), actualSectionResult.AssemblyGroup); Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedSectionAssemblyResult.AssemblyMethod), actualSectionResult.AssemblyMethod); }
private static void AssertCombinedFailureMechanismSectionResults(IEnumerable <ExportableFailureMechanismCombinedSectionAssemblyResult> expectedCombinedSectionAssemblyResults, IEnumerable <SerializableCombinedFailureMechanismSectionAssemblyResult> actualCombinedSectionAssemblyResults) { int expectedNrOfCombinedSectionAssemblies = expectedCombinedSectionAssemblyResults.Count(); Assert.AreEqual(expectedNrOfCombinedSectionAssemblies, actualCombinedSectionAssemblyResults.Count()); for (var i = 0; i < expectedNrOfCombinedSectionAssemblies; i++) { ExportableFailureMechanismCombinedSectionAssemblyResult expectedSectionAssembly = expectedCombinedSectionAssemblyResults.ElementAt(i); SerializableCombinedFailureMechanismSectionAssemblyResult actualSectionAssembly = actualCombinedSectionAssemblyResults.ElementAt(i); AssertCombinedFailureMechanismSectionAssemblyResult(expectedSectionAssembly, actualSectionAssembly); } }
public void Create_SectionResultWithInvalidAssemblyGroup_ThrowsAssemblyCreatorException(FailureMechanismSectionAssemblyGroup assemblyGroup) { // Setup var random = new Random(21); var sectionResult = new ExportableFailureMechanismCombinedSectionAssemblyResult( new ExportableFailureMechanismSubSectionAssemblyResult(assemblyGroup, random.NextEnumValue <ExportableAssemblyMethod>()), random.NextEnumValue <ExportableFailureMechanismType>(), "code", "name"); // Call void Call() => SerializableCombinedFailureMechanismSectionAssemblyResultCreator.Create(sectionResult); // Assert var exception = Assert.Throws <AssemblyCreatorException>(Call); Assert.AreEqual("The assembly result is invalid and cannot be created.", exception.Message); }
public void Constructor_WithArguments_ExpectedValues() { // Setup const string code = "code"; const string name = "name"; var random = new Random(21); var combinedSectionAssembly = new ExportableFailureMechanismSubSectionAssemblyResult( random.NextEnumValue <FailureMechanismSectionAssemblyGroup>(), random.NextEnumValue <ExportableAssemblyMethod>()); var failureMechanismType = random.NextEnumValue <ExportableFailureMechanismType>(); // Call var assemblyResult = new ExportableFailureMechanismCombinedSectionAssemblyResult( combinedSectionAssembly, failureMechanismType, code, name); // Assert Assert.AreSame(combinedSectionAssembly, assemblyResult.SectionAssemblyResult); Assert.AreEqual(failureMechanismType, assemblyResult.FailureMechanismType); Assert.AreEqual(code, assemblyResult.Code); Assert.AreEqual(name, assemblyResult.Name); }
public void Create_WithExportableFailureMechanismCombinedSectionAssemblyResult_ReturnsSerializableCombinedFailureMechanismSectionAssemblyResult() { // Setup var random = new Random(21); var sectionResult = new ExportableFailureMechanismCombinedSectionAssemblyResult( CreateSectionAssemblyResult(), random.NextEnumValue <ExportableFailureMechanismType>(), "code", "name"); // Call SerializableCombinedFailureMechanismSectionAssemblyResult serializableResult = SerializableCombinedFailureMechanismSectionAssemblyResultCreator.Create(sectionResult); // Assert Assert.AreEqual(SerializableFailureMechanismTypeCreator.Create(sectionResult.FailureMechanismType), serializableResult.FailureMechanismType); Assert.AreEqual(sectionResult.Code, serializableResult.GenericFailureMechanismCode); ExportableFailureMechanismSubSectionAssemblyResult expectedSectionAssemblyResult = sectionResult.SectionAssemblyResult; Assert.AreEqual(SerializableFailureMechanismSectionAssemblyGroupCreator.Create(expectedSectionAssemblyResult.AssemblyGroup), serializableResult.AssemblyGroup); Assert.AreEqual(SerializableAssemblyMethodCreator.Create(expectedSectionAssemblyResult.AssemblyMethod), serializableResult.AssemblyMethod); }
/// <summary> /// Creates an instance of <see cref="SerializableCombinedFailureMechanismSectionAssemblyResult"/> /// based on <paramref name="sectionResult"/>. /// </summary> /// <param name="sectionResult">The <see cref="ExportableFailureMechanismCombinedSectionAssemblyResult"/> /// to create a <see cref="SerializableCombinedFailureMechanismSectionAssemblyResult"/> for.</param> /// <returns>A <see cref="SerializableCombinedFailureMechanismSectionAssemblyResult"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="sectionResult"/> is <c>null</c>.</exception> /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="sectionResult"/> /// is invalid to create a serializable counterpart for.</exception> public static SerializableCombinedFailureMechanismSectionAssemblyResult Create(ExportableFailureMechanismCombinedSectionAssemblyResult sectionResult) { if (sectionResult == null) { throw new ArgumentNullException(nameof(sectionResult)); } ExportableFailureMechanismSubSectionAssemblyResult sectionResultSectionAssemblyResult = sectionResult.SectionAssemblyResult; if (sectionResultSectionAssemblyResult.AssemblyGroup == FailureMechanismSectionAssemblyGroup.NoResult || sectionResultSectionAssemblyResult.AssemblyGroup == FailureMechanismSectionAssemblyGroup.Dominant) { throw new AssemblyCreatorException("The assembly result is invalid and cannot be created."); } return(new SerializableCombinedFailureMechanismSectionAssemblyResult( SerializableAssemblyMethodCreator.Create(sectionResultSectionAssemblyResult.AssemblyMethod), SerializableFailureMechanismTypeCreator.Create(sectionResult.FailureMechanismType), sectionResult.Code, sectionResult.Name, SerializableFailureMechanismSectionAssemblyGroupCreator.Create(sectionResultSectionAssemblyResult.AssemblyGroup))); }
private static void AssertExportableFailureMechanismCombinedSectionAssemblyResult(IFailureMechanism failureMechanism, ExportableFailureMechanismType expectedFailureMechanismType, ExportableFailureMechanismCombinedSectionAssemblyResult actualExportableFailureMechanismCombinedSectionAssemblyResult) { Assert.AreEqual(failureMechanism.Code, actualExportableFailureMechanismCombinedSectionAssemblyResult.Code); Assert.AreEqual(expectedFailureMechanismType, actualExportableFailureMechanismCombinedSectionAssemblyResult.FailureMechanismType); Assert.AreEqual(failureMechanism.Name, actualExportableFailureMechanismCombinedSectionAssemblyResult.Name); Assert.AreEqual(FailureMechanismSectionAssemblyGroup.Dominant, actualExportableFailureMechanismCombinedSectionAssemblyResult.SectionAssemblyResult.AssemblyGroup); Assert.AreEqual(ExportableAssemblyMethod.BOI3B1, actualExportableFailureMechanismCombinedSectionAssemblyResult.SectionAssemblyResult.AssemblyMethod); }