public void TestPhoneAddPartWithInvalidPart() { Phone phone = new Phone("iPhone"); IPart pcPart = new PCPart("Keyboard", 13); Assert.Throws <InvalidOperationException>(() => phone.AddPart(pcPart)); }
public void TestShouldNotBeAbleToAddNonPhonePart() { IPart pcPart = new PCPart("CD", 10m); IRepairable phone = new Phone(makeTest); Assert.Throws <InvalidOperationException>(() => phone.AddPart(pcPart)); }
public void TestShouldNotBeAbleToAddNonLaptopPart() { IPart pcPart = new PCPart("CD", 10m); IRepairable laptop = new Laptop(makeTest); Assert.Throws <InvalidOperationException>(() => laptop.AddPart(pcPart)); }
public void TestAddPartLaptopWithNonLaptopPart() { IPart part = new PCPart("GPU", 150, false); string expectedExceptionMessage = $"You cannot add {part.GetType().Name} to {this.laptop.GetType().Name}!"; Assert.That(() => this.laptop.AddPart(part), Throws.InvalidOperationException.With.Message.EqualTo(expectedExceptionMessage)); }
public void PCPartReportShouldReturnStringContainingNameCostAndIsBrokenPropertiesAsPartOfIt() { var pcPart = new PCPart("ram", 100m, true); StringAssert.Contains($"{pcPart.Name}", pcPart.Report(), "Report string doesn't contain Name property"); StringAssert.Contains($"{pcPart.Cost}", pcPart.Report(), "Report string doesn't contain Cost property"); StringAssert.Contains($"{pcPart.IsBroken}", pcPart.Report(), "Report string doesn't contain IsBroken property"); }
public void TestPCPartShouldBeInstantiatedWith3parameters() { IPart pcPart = new PCPart(PartName, PartCost, PartIsBroken); Assert.AreEqual(PartName, pcPart.Name); Assert.AreEqual((PartCost * multiplierPCPart), pcPart.Cost); Assert.AreEqual(PartIsBroken, pcPart.IsBroken); }
public void PcPartRepairShouldWorksCorrectly() { var part = new PCPart("JustLaptopPart", 2.50M, true); part.Repair(); Assert.IsFalse(part.IsBroken); }
public void TestRepairPCPartShouldFixBrokenPart() { IPart pcPart = new PCPart(PartName, PartCost); pcPart.Repair(); Assert.IsTrue(pcPart.IsBroken == false); }
public void PCPartConstructorWithThreeParametersShouldSetIsBrokenCorrectly() { var PCPart = new PCPart("ram", 100m, true); bool actualIsBroken = PCPart.IsBroken; Assert.IsTrue(actualIsBroken); }
public void PCPartRepairShouldTurnIsBrokenToFalse() { var PCPart = new PCPart("ram", 100m, true); PCPart.Repair(); Assert.IsFalse(PCPart.IsBroken); }
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 PCPartConstructorWithThreeParametersShouldSetNameCorrectly() { var PCPart = new PCPart("Ram", 100m, true); string expectedName = "Ram"; string actualName = PCPart.Name; Assert.AreEqual(expectedName, actualName); }
public void TestIfPCPartReportWorksCorrectly() { string expectedResult = $"Fan - {(60 * 1.2m):F2}$" + Environment.NewLine + $"Broken: True"; IPart pcPart = new PCPart("Fan", 60, true); Assert.AreEqual(expectedResult, pcPart.Report()); }
public void PCPartConstructorWithThreeParametersShouldSetCostCorrectly() { var PCPart = new PCPart("ram", 100m, true); decimal expectedCost = 100m * 1.2m; decimal actualCost = PCPart.Cost; Assert.AreEqual(expectedCost, actualCost); }
public void TestIfRepairPartWorksCorrectly() { bool expectedResult = false; PCPart pcPart = new PCPart("VideoCard", 500m, true); pcPart.Repair(); Assert.AreEqual(expectedResult, pcPart.IsBroken); }
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 TestAddPartPhoneWithNonPhonePart() { IPart part = new PCPart("GPU", 150, false); Phone phone = new Phone("Samsung"); string expectedExceptionMessage = $"You cannot add {part.GetType().Name} to {phone.GetType().Name}!"; Assert.That(() => phone.AddPart(part), Throws.InvalidOperationException.With.Message.EqualTo(expectedExceptionMessage)); }
public void TestReportPCPartShouldReturnCorrectMessage() { IPart pcPart = new PCPart(PartName, PartCost, PartIsBroken); string expected = $"{PartName} - {(PartCost*multiplierPCPart):f2}$" + Environment.NewLine + $"Broken: {PartIsBroken}"; string actual = pcPart.Report(); Assert.AreEqual(expected, actual); }
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 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 PcPartReportShouldGiveCorrectInfo() { var part = new PCPart("JustLaptopPart", 3.50M, false); var expectedReport = $"JustLaptopPart - 4.20$" + Environment.NewLine + $"Broken: False"; Assert.AreEqual(expectedReport, part.Report()); }
public void Setup() { this.laptop = new Laptop("LaptopMake"); this.pc = new PC("PCMake"); this.phone = new Phone("PhoneMake"); this.laptopPart1 = new LaptopPart("RAM", 10, true); this.laptopPart2 = new LaptopPart("HDD", 50, false); this.pcPart = new PCPart("SSD", 15); this.phonePart = new PhonePart("Camera", 20); }
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 LaptopAddPartShouldThrowExceptionIfPartIsWrong() { var laptop = new Laptop("Dell"); var pcPart = new PCPart("PcPart", 3.50m); var phonePart = new PhonePart("PhonePart", 2.50m); Assert.Throws <InvalidOperationException>(() => laptop.AddPart(pcPart)); Assert.Throws <InvalidOperationException>(() => laptop.AddPart(phonePart)); }
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 PhoneAddPartShouldThrowExceptionIfPartIsWrong() { var phone = new Phone("iPhone"); var laptopPart = new LaptopPart("LaptopPart", 3.50m); var pcPart = new PCPart("PcPart", 2.50m); Assert.Throws <InvalidOperationException>(() => phone.AddPart(laptopPart)); Assert.Throws <InvalidOperationException>(() => phone.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 PC_Part_ReportTest() { var pcPart = new PCPart("aaa", 100); var pcPart2 = new PCPart("bbb", 200, true); Assert.AreEqual("aaa - 120.00$" + Environment.NewLine + $"Broken: False", pcPart.Report()); Assert.AreEqual("bbb - 240.00$" + Environment.NewLine + $"Broken: True", pcPart2.Report()); }