public void TestPCAddPartWithInvalidPart() { PC pc = new PC("Toshiba"); IPart phonePart = new PhonePart("Keyboard", 85); Assert.Throws <InvalidOperationException>(() => pc.AddPart(phonePart)); }
public void Test_Repair() { var newPhonePart = new PhonePart("valid", 2, true); newPhonePart.Repair(); Assert.AreEqual(false, newPhonePart.IsBroken); }
public void TestRepairPhonePartShouldFixBrokenPart() { IPart phonePart = new PhonePart(PartName, PartCost); phonePart.Repair(); Assert.IsTrue(phonePart.IsBroken == false); }
public void PhonePartRepairShouldTurnIsBrokenToFalse() { var phonePart = new PhonePart("ram", 100m, true); phonePart.Repair(); Assert.IsFalse(phonePart.IsBroken); }
public void TestPhonePartShouldBeInstantiatedWith3parameters() { IPart phonePart = new PhonePart(PartName, PartCost, PartIsBroken); Assert.AreEqual(PartName, phonePart.Name); Assert.AreEqual((PartCost * multiplierPhonePart), phonePart.Cost); Assert.AreEqual(PartIsBroken, phonePart.IsBroken); }
public void PhonePartReportShouldReturnStringContainingNameCostAndIsBrokenPropertiesAsPartOfIt() { var phonePart = new PhonePart("ram", 100m, true); StringAssert.Contains($"{phonePart.Name}", phonePart.Report(), "Report string doesn't contain Name property"); StringAssert.Contains($"{phonePart.Cost}", phonePart.Report(), "Report string doesn't contain Cost property"); StringAssert.Contains($"{phonePart.IsBroken}", phonePart.Report(), "Report string doesn't contain IsBroken property"); }
public void NameSetter_ShouldThrow_ExceptionIfNullOrEmpty() { //Assert Assert.Throws <ArgumentException>(() => { PhonePart itemPart = new PhonePart("", 10m); }); }
public void PhonePartConstructorWithThreeParametersShouldSetIsBrokenCorrectly() { var PhonePart = new PhonePart("ram", 100m, true); bool actualIsBroken = PhonePart.IsBroken; Assert.IsTrue(actualIsBroken); }
public void CostSetter_ShouldThrow_ExceptionIfNegative() { //Assert Assert.Throws <ArgumentException>(() => { PhonePart itemPart = new PhonePart("Button", -1m); }); }
public void PhonePartRepairShouldWorksCorrectly() { var part = new PhonePart("JustLaptopPart", 2.50M, true); part.Repair(); Assert.IsFalse(part.IsBroken); }
public void Test_Report() { var newPhonePart = new PhonePart("valid", 2, true); string report = $"{newPhonePart.Name} - {newPhonePart.Cost:f2}$" + Environment.NewLine + $"Broken: {newPhonePart.IsBroken}"; Assert.AreEqual(report, newPhonePart.Report()); }
public void PhonePartConstructorWithThreeParametersShouldSetNameCorrectly() { var PhonePart = new PhonePart("Ram", 100m, true); string expectedName = "Ram"; string actualName = PhonePart.Name; Assert.AreEqual(expectedName, actualName); }
public void PhonePartConstructorWithThreeParametersShouldSetCostCorrectly() { var PhonePart = new PhonePart("ram", 100m, true); decimal expectedCost = 100m * 1.3m; decimal actualCost = PhonePart.Cost; Assert.AreEqual(expectedCost, actualCost); }
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 TestRepairNotBrokenPhonePart() { IPart phonePart = new PhonePart("CD", 10m, false); IRepairable phone = new Phone(makeTest); phone.AddPart(phonePart); Assert.Throws <InvalidOperationException>(() => phone.RepairPart("CD")); }
public void TestRepairPhonePartWithEmptyName() { IPart phonePart = new PhonePart("CD", 10m, true); IRepairable phone = new Phone(makeTest); phone.AddPart(phonePart); Assert.Throws <ArgumentException>(() => phone.RepairPart(String.Empty)); }
public void TestShouldNotBeAbleToAddExistingPhonePart() { IPart phonePart = new PhonePart("CD", 10m); IRepairable phone = new Phone(makeTest); phone.AddPart(phonePart); Assert.Throws <InvalidOperationException>(() => phone.AddPart(phonePart)); }
public void TestShouldBeAbleToAddPhonePart() { IPart phonePart = new PhonePart("CD", 10m); IRepairable phone = new Phone(makeTest); phone.AddPart(phonePart); Assert.AreEqual(1, phone.Parts.Count); }
public void AddPart(PhonePart toAdd) { // TODO check that one unique part can only be added once // TODO check that the correct amount of screws is assembled var tmp = parts.ToList(); tmp.Add(toAdd); parts = tmp.ToArray(); }
public void PhonePartReportShouldGiveCorrectInfo() { var part = new PhonePart("JustLaptopPart", 5.50M, true); var expectedReport = $"JustLaptopPart - 7.15$" + Environment.NewLine + $"Broken: True"; Assert.AreEqual(expectedReport, part.Report()); }
public void PhoneRepairPartMethodCannotRepairNonBrokenPart() { var phone = new Phone("iPhone"); var part = new PhonePart("PhonePart", 5.50m, false); phone.AddPart(part); Assert.Throws <InvalidOperationException>(() => phone.RepairPart("PhonePart")); }
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 TestRepairPhonePartWithNotExistingPCPart() { IPart phonePart = new PhonePart("CD", 10m); IPart phonePart2 = new PhonePart("HDD", 100m); IRepairable phone = new Phone(makeTest); phone.AddPart(phonePart); Assert.Throws <InvalidOperationException>(() => phone.RepairPart("HDD")); }
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 PhoneRepairPartMethodShouldWorksCorrectly() { var phone = new Phone("iPhone"); var part = new PhonePart("PhonePart", 12.75m, true); phone.AddPart(part); phone.RepairPart(part.Name); Assert.IsFalse(part.IsBroken); }
public void PhoneRemovePartMethodCannotRemoveNonExistingPart() { var phone = new Phone("iPhone"); var part = new PhonePart("PhonePart", 5.50m); phone.AddPart(part); Assert.Throws <InvalidOperationException>(() => phone.RemovePart("LaptopPart")); }
public void PhoneAddPartShouldThrowExceptionIfPartIsAlreadyExisting() { var phone = new Phone("iPhone"); var phonePart = new PhonePart("PhonePart", 3.50m); phone.AddPart(phonePart); Assert.Throws <InvalidOperationException>(() => phone.AddPart(phonePart)); }
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 Phone_Part_ReportTest() { var phonePart = new PhonePart("aaa", 100); var phonePart2 = new PhonePart("bbb", 200, true); Assert.AreEqual("aaa - 130.00$" + Environment.NewLine + $"Broken: False", phonePart.Report()); Assert.AreEqual("bbb - 260.00$" + Environment.NewLine + $"Broken: True", phonePart2.Report()); }
public void TestIfPhoneAddPartWorksCorrectly() { IPart part = new PhonePart("GPU", 150, false); Phone phone = new Phone("Samsung"); phone.AddPart(part); Assert.That(phone.Parts, Has.Member(part)); }