public void GetAllFromBrand_Should_Return_Correct_Order() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2200, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2800, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); var expected = new List <Computer>() { new Computer(4, Brand.DELL, 2800, 15.6, "grey"), new Computer(1, Brand.DELL, 2300, 15.6, "grey"), new Computer(3, Brand.DELL, 2200, 15.6, "grey") }; var actual = microsystems.GetAllFromBrand(Brand.DELL).ToList(); //Assert Assert.IsTrue(actual.SequenceEqual(expected)); }
public void GetInRangePrice_Should_Return_Correct_Order() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(7, Brand.DELL, 2400, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2200, 15.6, "blue"); var computer3 = new Computer(6, Brand.DELL, 2800, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2500, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); var expected = new List <Computer>() { new Computer(5, Brand.ACER, 2500, 15.6, "grey"), new Computer(7, Brand.DELL, 2400, 15.6, "grey"), new Computer(3, Brand.DELL, 2200, 15.6, "blue") }; var actual = microsystems.GetInRangePrice(2200, 2500); //Assert CollectionAssert.AreEqual(expected, actual); }
public void GetComputer_Should_Return_Correct_Computer() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); var expectedNumber = 3; var expectedBrand = Brand.DELL; var actualNumber = microsystems.GetComputer(3).Number; var actualBrand = microsystems.GetComputer(3).Brand; //Assert Assert.AreEqual(expectedNumber, actualNumber); Assert.AreEqual(expectedBrand, actualBrand); }
public void GetAllFromBrand_Should_Return_Correct_Order_1() { //Arrange var microsystems = new Microsystems(); double[] prices = new double[] { 1500, 2200, 3000, 1256, 3564, 4583, 1236, }; int itemsCount = 1000000; for (int i = 0; i < itemsCount; i++) { var computer = new Computer(i, Brand.DELL, i, 15.6, "grey"); microsystems.CreateComputer(computer); } for (int i = 0; i < 100; i++) { var actual = microsystems.GetAllFromBrand(Brand.DELL).ToList(); Assert.AreEqual(itemsCount, actual.Count); } //Assert }
public void Create_Computer_Should_Throw_Exception_With_Existing_Id() { //Arrange var microsystems = new Microsystems(); var computerValid = new Computer(1, Brand.ASUS, 1800, 14, "black"); var invalidComputer = new Computer(1, Brand.ASUS, 1800, 14, "black"); //Act microsystems.CreateComputer(computerValid); //Arrange Assert.Throws <ArgumentException>(() => microsystems.CreateComputer(invalidComputer)); }
public void Count_Should_Work_Correct() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); //Assert Assert.AreEqual(3, microsystems.Count()); }
public void Create_Computer_Count_Should_Increase() { //Arrange var microsystems = new Microsystems(); var computer1 = new Computer(1, Brand.ACER, 1120, 15.6, "grey"); var computer2 = new Computer(2, Brand.ASUS, 2000, 15.6, "red"); //Act var expectedCount = 2; microsystems.CreateComputer(computer1); microsystems.CreateComputer(computer2); var actualCount = microsystems.Count(); //Assert Assert.AreEqual(expectedCount, actualCount); }
public void GetComputer_Should_Throw_Exception_With_Invalid_Number() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); //Assert Assert.Throws <ArgumentException>(() => microsystems.GetComputer(13)); }
public void Remove_Should_Decrease_Count() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.Remove(1); //Assert Assert.AreEqual(2, microsystems.Count()); }
public void After_Remove_Computer_Should_Not_Exist() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.Remove(1); //Assert Assert.IsFalse(microsystems.Contains(1)); }
public void Upgrade_Ram_Should_Throw_Exception_With_Invalid_Number() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); //Assert Assert.Throws <ArgumentException>(() => microsystems.UpgradeRam(16, 12)); }
public void Remove_With_Brand_Should_Decrease_Count() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 15, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 17, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 10, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); microsystems.RemoveWithBrand(Brand.DELL); //Assert Assert.AreEqual(1, microsystems.Count()); }
public void Remove_With_Non_Existing_Brand_Should_Throw_Exception() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); //Assert Assert.Throws <ArgumentException>(() => microsystems.RemoveWithBrand(Brand.HP)); }
public void GetAllFromBrand_Should_Return_Correct_Count() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); var expectedCount = 3; var actualCount = microsystems.GetAllFromBrand(Brand.DELL).Count(); //Assert Assert.AreEqual(expectedCount, actualCount); }
public void GetAllWithScreenSize_Should_Return_Correct_Count() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2200, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2800, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); var expected = 4; var actual = microsystems.GetAllWithScreenSize(15.6).Count(); //Assert Assert.AreEqual(expected, actual); }
public void GetInRangePrice_Should_Return_Empty_Collection() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2200, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2800, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); var expected = Enumerable.Empty <Computer>(); var actual = microsystems.GetInRangePrice(2100, 2199); //Assert CollectionAssert.AreEqual(expected, actual); }
public void Contains_Should_Return_False_With_Invalid_Number() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); //Assert Assert.IsFalse(microsystems.Contains(3)); }
public void Upgrade_Ram_Should_Change_Ram() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); microsystems.UpgradeRam(16, 1); var expectedRam = 16; var actualRam = microsystems.GetComputer(1).RAM; //Assert Assert.AreEqual(expectedRam, actualRam); }
public void Remove_With_Brand_Should_Not_Contain_Removed_Computers() { //Arrange var microsystems = new Microsystems(); var computer = new Computer(1, Brand.DELL, 2300, 15.6, "grey"); var computer2 = new Computer(3, Brand.DELL, 2300, 15.6, "grey"); var computer3 = new Computer(4, Brand.DELL, 2300, 15.6, "grey"); var computer4 = new Computer(5, Brand.ACER, 2300, 15.6, "grey"); //Act microsystems.CreateComputer(computer); microsystems.CreateComputer(computer2); microsystems.CreateComputer(computer3); microsystems.CreateComputer(computer4); microsystems.RemoveWithBrand(Brand.DELL); //Assert Assert.IsFalse(microsystems.Contains(1)); Assert.IsFalse(microsystems.Contains(3)); Assert.IsFalse(microsystems.Contains(4)); }