public void Devices_AddPartThrowsException_WhenPartNotCompatible(string type) { switch (type) { case "Laptop": var laptop = new Laptop("make"); Assert.Throws <InvalidOperationException>(() => laptop.AddPart(phonePart)) .Message.Equals($"You cannot add {phonePart.GetType().Name} to {this.GetType().Name}!"); Assert.Throws <InvalidOperationException>(() => laptop.AddPart(pcPart)) .Message.Equals($"You cannot add {pcPart.GetType().Name} to {this.GetType().Name}!"); break; case "PC": var pc = new PC("make"); Assert.Throws <InvalidOperationException>(() => pc.AddPart(laptopPart)) .Message.Equals($"You cannot add {laptopPart.GetType().Name} to {this.GetType().Name}!"); Assert.Throws <InvalidOperationException>(() => pc.AddPart(phonePart)) .Message.Equals($"You cannot add {phonePart.GetType().Name} to {this.GetType().Name}!"); break; case "Phone": var phone = new Phone("make"); Assert.Throws <InvalidOperationException>(() => phone.AddPart(pcPart)) .Message.Equals($"You cannot add {pcPart.GetType().Name} to {this.GetType().Name}!"); Assert.Throws <InvalidOperationException>(() => phone.AddPart(laptopPart)) .Message.Equals($"You cannot add {laptopPart.GetType().Name} to {this.GetType().Name}!"); break; } }
public void TestShouldNotBeAbleToAddExistingPCPart() { IPart pcPart = new PCPart("CD", 10m); IRepairable pc = new PC(makeTest); pc.AddPart(pcPart); Assert.Throws <InvalidOperationException>(() => pc.AddPart(pcPart)); }
public void PcAddPartShouldThrowExceptionIfPartIsAlreadyExisting() { var pc = new PC("Dell"); var pcPart = new PCPart("PcPart", 3.50m); pc.AddPart(pcPart); Assert.Throws <InvalidOperationException>(() => pc.AddPart(pcPart)); }
public void PcAddPartShouldThrowExceptionIfPartIsWrong() { var pc = new PC("Acer"); var laptopPart = new LaptopPart("LaptopPart", 3.50m); var phonePart = new PhonePart("PhonePart", 2.50m); Assert.Throws <InvalidOperationException>(() => pc.AddPart(laptopPart)); Assert.Throws <InvalidOperationException>(() => pc.AddPart(phonePart)); }
public void PcAddPartShouldWorksCorrectly() { var pc = new PC("Dell"); var pcPart1 = new PCPart("PcPart1", 3.50m); var pcPart2 = new PCPart("PcPart2", 3.50m); pc.AddPart(pcPart1); pc.AddPart(pcPart2); var expectedCount = 2; Assert.AreEqual(expectedCount, pc.Parts.Count); }
public void PcRemovePartMethodShouldWorkCorrectly() { var pc = new PC("Dell"); var part1 = new PCPart("PcPart1", 7.50m); var part2 = new PCPart("PcPart2", 3.50m); pc.AddPart(part1); pc.AddPart(part2); pc.RemovePart(part1.Name); var expectedCount = 1; Assert.AreEqual(expectedCount, pc.Parts.Count); }
public void TestPCAddPartWithInvalidPart() { PC pc = new PC("Toshiba"); IPart phonePart = new PhonePart("Keyboard", 85); Assert.Throws <InvalidOperationException>(() => pc.AddPart(phonePart)); }
public void TestShouldNotBeAbleToAddNonPCPart() { IPart laptopPart = new LaptopPart("CD", 10m); IRepairable pc = new PC(makeTest); Assert.Throws <InvalidOperationException>(() => pc.AddPart(laptopPart)); }
public void TestRepairNotBrokenPCPart() { IPart pcPart = new PCPart("CD", 10m, false); IRepairable pc = new PC(makeTest); pc.AddPart(pcPart); Assert.Throws <InvalidOperationException>(() => pc.RepairPart("CD")); }
public void TestRepairPCPartWithEmptyName() { IPart pcPart = new PCPart("CD", 10m, true); IRepairable pc = new PC(makeTest); pc.AddPart(pcPart); Assert.Throws <ArgumentException>(() => pc.RepairPart(String.Empty)); }
public void TestShouldBeAbleToAddPCPart() { IPart pcPart = new PCPart("CD", 10m); IRepairable pc = new PC(makeTest); pc.AddPart(pcPart); Assert.AreEqual(1, pc.Parts.Count); }
public void TestAddPartPCeWithNonPCPart() { IPart part = new PhonePart("GPU", 150, false); PC pc = new PC("Asus"); string expectedExceptionMessage = $"You cannot add {part.GetType().Name} to {pc.GetType().Name}!"; Assert.That(() => pc.AddPart(part), Throws.InvalidOperationException.With.Message.EqualTo(expectedExceptionMessage)); }
public void PcRepairPartMethodCannotRepairNonBrokenPart() { var pc = new PC("Dell"); var part = new PCPart("LaptopPart", 5.50m, false); pc.AddPart(part); Assert.Throws <InvalidOperationException>(() => pc.RepairPart("LaptopPart")); }
public void PcRepairPartMethodShouldWorksCorrectly() { var pc = new PC("Dell"); var part = new PCPart("PcPart", 3.25m, true); pc.AddPart(part); pc.RepairPart(part.Name); Assert.IsFalse(part.IsBroken); }
public void PcRemovePartMethodCannotRemoveNonExistingPart() { var pc = new PC("Dell"); var part = new PCPart("PcPart", 5.50m); pc.AddPart(part); Assert.Throws <InvalidOperationException>(() => pc.RemovePart("LaptopPart")); }
public void TestRepairPCPartWithNotExistingPCPart() { IPart pcPart = new PCPart("CD", 10m); IPart pcPart2 = new PCPart("HDD", 100m); IRepairable pc = new PC(makeTest); pc.AddPart(pcPart); Assert.Throws <InvalidOperationException>(() => pc.RepairPart("HDD")); }
public void TestIfPCAddPartWorksCorrectly() { IPart part = new PCPart("GPU", 150, false); PC pc = new PC("Asus"); pc.AddPart(part); Assert.That(pc.Parts, Has.Member(part)); }
public void TestIfPCAddPartWorksCorrectly() { int expectedCount = 1; PC pc = new PC("Toshiba"); IPart pcPart = new PCPart("Keyboard", 40); pc.AddPart(pcPart); Assert.AreEqual(expectedCount, pc.Parts.Count); }
public void TestRemoveCorrectlyPCPart() { IPart pcPart = new PCPart("CD", 10m); IRepairable pc = new PC(makeTest); pc.AddPart(pcPart); pc.RemovePart("CD"); int expectedCount = 0; int actualCount = pc.Parts.Count; Assert.AreEqual(expectedCount, actualCount); }
public void TestCorrectlyRepairPCPart() { IPart pcPart = new PCPart("CD", 10m, true); IRepairable pc = new PC(makeTest); pc.AddPart(pcPart); pc.RepairPart("CD"); bool expectedIsBroken = false; bool actualIsBroken = pc.Parts.First(p => p.Name == "CD").IsBroken; Assert.AreEqual(expectedIsBroken, actualIsBroken); }
public void DeviceRepairMethod_Test() { var pc = new PC("pc"); var phone = new Phone("phone"); var laptop = new Laptop("laptop"); pc.AddPart(pcPart); phone.AddPart(phonePart); laptop.AddPart(laptopPart); pc.RepairPart("pcPart"); phone.RepairPart("phonePart"); laptop.RepairPart("laptopPart"); Assert.That(pcPart.IsBroken == false); Assert.That(laptopPart.IsBroken == false); Assert.That(phonePart.IsBroken == false); }