public void Return_Zero_Cost_If_Part_Do_Not_Exists() { var partDescription = new PartDescription("Part A", "Dublin"); var inventory = new Inventory(); PartCost cost = inventory.PreviewCheckOut(partDescription, quantity: 2, priceStrategy: new FifoPriceStrategy()); cost.Total.Should().Be(0); }
public void Check_In_Parts() { const string partType = "Part A"; const string warehouse = "Dublin"; var partDescription = new PartDescription(partType, warehouse); var inventory = new Inventory(); var batch = new Batch(partType, partPrice: 100, quantity: 1); inventory.CheckIn(batch, warehouse); PartCost cost = inventory.PreviewCheckOut(partDescription, quantity: 1, priceStrategy: new FifoPriceStrategy()); cost.Total.Should().Be(100); }
public void Return_Cost_Having_One_Batch_And_Enough_Quantity_Of_That_Part() { const string partType = "Part A"; const string warehouse = "Dublin"; var partDescription = new PartDescription(partType, warehouse); var inventory = new Inventory(); var batch = new Batch(partType, partPrice: 100, quantity: 2); inventory.CheckIn(batch, warehouse); PartCost cost = inventory.PreviewCheckOut(partDescription, quantity: 2, priceStrategy: new FifoPriceStrategy()); cost.Total.Should().Be(200); }
public void Return_Cost_Having_Several_Batches_Of_That_Part_With_LIFO_Strategy() { const string partType = "Part A"; const string warehouse = "Dublin"; var partDescription = new PartDescription(partType, warehouse); var inventory = new Inventory(); var batch1 = new Batch(partType, partPrice: 100, quantity: 2); var batch2 = new Batch(partType, partPrice: 150, quantity: 4); inventory.CheckIn(batch1, warehouse); inventory.CheckIn(batch2, warehouse); PartCost cost = inventory.PreviewCheckOut(partDescription, quantity: 5, priceStrategy: new LifoPriceStrategy()); cost.Total.Should().Be(700); }
public void Check_Out_Parts() { const string partType = "Part A"; const string warehouse = "Dublin"; var partDescription = new PartDescription(partType, warehouse); var inventory = new Inventory(); var batch1 = new Batch(partType, partPrice: 100, quantity: 2); var batch2 = new Batch(partType, partPrice: 100, quantity: 4); inventory.CheckIn(batch1, warehouse); inventory.CheckIn(batch2, warehouse); inventory.CheckOut(partDescription, quantity: 5, priceStrategy: new LifoPriceStrategy()); inventory.GetQuantity(partDescription).Should().Be(1); }
public void FirstWordTest_GivenSpace() { var desc = new PartDescription("BOLT THREADED"); Assert.Equal("BOLT", desc.FirstWord()); }
public static bool IsHybridLines(this PartDescription description) { return(description.StartsWith("LINE") && description.Contains("HYBR")); }
public static bool IsHose(this PartDescription description) { return(description.StartsWith("HOSE")); }
public static bool IsGasket(this PartDescription description) { return(description.StartsWith("GASKET")); }
public static bool IsZinc(this PartDescription description) { return(description.Contains("ZINC")); }
public static bool IsNut(this PartDescription description) { return(description.StartsWith("NUT")); }
public static bool IsTurbocharger(this PartDescription description) { return(description.StartsWith("TURBO")); }
public static bool IsPumpGroup(this PartDescription description) { return(description.StartsWith("PUMP GP")); }
public static bool IsControlGroup(this PartDescription description) { return(description.StartsWith("CONTROL GP")); }
public static bool IsCable(this PartDescription description) { return(description.StartsWith("CABLE AS")); }
public static bool IsSpacer(this PartDescription description) { return(description.StartsWith("SPACER")); }
public static bool IsBolt(this PartDescription description) { return(description.StartsWith("BOLT")); }
public static bool IsBearingOrBushing(this PartDescription description) { return(description.StartsWith("BUSHING") || description.StartsWith("BEARING")); }
public static bool IsLocknut(this PartDescription description) { return(description.StartsWith("LOCKNUT")); }
public static bool IsCompositePart(this PartDescription description) { return(description.Contains(" AS") || description.Contains(" GP") || description.Contains(" AR")); }
public static bool IsSeal(this PartDescription description) { return(description.StartsWith("SEAL")); }
public static bool IsKitPart(this PartDescription description) { return(description.StartsWith("KIT-")); }
public static bool IsGrommet(this PartDescription description) { return(description.StartsWith("GROMMET")); }
public static bool IsSensor(this PartDescription description) { return(description.StartsWith("SENSOR")); }
public static bool IsSwitch(this PartDescription description) { return(description.StartsWith("SWITCH AS") || description.StartsWith("SWITCH GP")); }
public static bool IsHarnessAs(this PartDescription description) { return(description.StartsWith("HARNESS AS") || description.StartsWith("WIRE AS") || description.StartsWith("CABLE AS")); }
public static bool IsIntakeExhaustValve(this PartDescription description) { return(description.StartsWith("VALVE-IN") || description.StartsWith("VALVE-EX")); }
public static bool IsArrangement(this PartDescription description) { return(description.Contains(" AR-") || description.ToString().EndsWith(" AR")); }
public static ModelMesh[] ProcessContainer(IModelResourceContainer container, ModelShaderReference[] shaders, string note = null) { var parts = new List <PartDescription>((int)container.Header.PartInfoCount); var verts = new VertexFormat[container.VertexCount]; Span <int> indices = new int[container.Header.IndexCount]; var currentResource = 0; // process part info 0 resource if (container.Header.PartInfoCount > 0) { var partData = container.Resources[currentResource].Data.Span; for (var i = 0; i < container.Header.PartInfoCount; i++) { var start = i * 72; var elementType = (MeshElementType)partData.ReadUInt16At(start + 2); var matId = partData.ReadUInt16At(start + 4); var indexStart = partData.ReadUInt16At(start + 6); var indexCount = partData.ReadUInt16At(start + 8); var partDescription = new PartDescription(indexStart, indexCount, shaders[matId].ShaderId, elementType); parts.Add(partDescription); } currentResource++; } // process part info 2 resource if (container.Header.PartInfo2Count > 0) { // Not positive on what this is for, last ushort of the 8 bytes looks to be part index currentResource++; } // process part info 3 resource if (container.Header.PartInfo3Count > 0) { currentResource++; } // process indicies resource if (container.Header.IndexCount > 0) { var data = container.Resources[currentResource].Data.Span; for (var i = 0; i < container.Header.IndexCount; i++) { indices[i] = data.ReadUInt16At(i * 2); } currentResource++; } // process unknown resource if (container.Header.UknownDataLength > 0) { currentResource++; } // process unknown resource if (container.Header.UknownIndiciesCount > 0) { currentResource++; } // process Vertex Attribute Hint resource if (container.Header.VertexComponentCount > 0) { currentResource++; } // process vertex attribute resources if (container.Header.VertexComponentCount > 0) { if (container.Header.VertexComponentCount >= 1) { var posData = container.Resources[currentResource].Data.Span; // TODO: Find out why stride can be different/ how to know other than this method var itemStride = posData.Length / container.VertexCount; for (var i = 0; i < container.VertexCount; i++) { var vert = new VertexFormat(); vert.Position = posData.ReadVec3At(i * itemStride); verts[i] = vert; } currentResource++; } if (container.Header.VertexComponentCount >= 2) { var texData = container.Resources[currentResource].Data.Span; for (var i = 0; i < container.VertexCount; i++) { var vert = verts[i]; vert.TexCoords = texData.ReadVec2At(i * 8); verts[i] = vert; } currentResource++; } if (container.Header.VertexComponentCount >= 3) { var tbnData = container.Resources[currentResource].Data.Span; for (var i = 0; i < container.VertexCount; i++) { var vert = verts[i]; var start = i * 36; vert.Normal = tbnData.ReadVec3At(start); vert.Bitangent = tbnData.ReadVec3At(start + 12); vert.Tangent = tbnData.ReadVec3At(start + 24); verts[i] = vert; } currentResource++; } } var meshes = new List <ModelMesh>(parts.Count); foreach (var part in parts) { meshes.Add(new ModelMesh { Verticies = verts, Indices = indices.Slice(part.IndexStart, part.IndexCount).ToArray(), Shader = part.Shader, ElementType = part.ElementType, Note = note }); } return(meshes.ToArray()); }
public static bool IsWasher(this PartDescription description) { return(description.StartsWith("WASHER") && !description.StartsWith("WASHER-THR")); }