public void Get_Computers_By_Manufacturer_Method_Should_Return_Correct_Result() { var computerManager = new ComputerManager(); computerManager.AddComputer(new Computer("1", "1", 20000)); computerManager.AddComputer(new Computer("2", "2", 100)); computerManager.AddComputer(new Computer("2", "3", 200)); computerManager.AddComputer(new Computer("2", "4", 300)); var computers = computerManager .GetComputersByManufacturer("2") .ToList(); Assert.That(computers.Count, Is.EqualTo(3)); Assert.That(computers[0].Manufacturer, Is.EqualTo("2")); Assert.That(computers[1].Manufacturer, Is.EqualTo("2")); Assert.That(computers[2].Manufacturer, Is.EqualTo("2")); Assert.That(computers[0].Model, Is.EqualTo("2")); Assert.That(computers[1].Model, Is.EqualTo("3")); Assert.That(computers[2].Model, Is.EqualTo("4")); Assert.That(computers[0].Price, Is.EqualTo(100)); Assert.That(computers[1].Price, Is.EqualTo(200)); Assert.That(computers[2].Price, Is.EqualTo(300)); }
public void GetComputerByManufacturerShouldReturnCollectionWithCount2() { string manufacturer = "IBM"; string model = "Xeon"; decimal price = 1000m; string manufacturer2 = manufacturer; string model2 = "SomeModel"; decimal price2 = 1500m; string manufacturer3 = "NVIDIA"; string model3 = "nVidiaModel"; decimal price3 = 2500m; Computer computer = new Computer(manufacturer, model, price); Computer computer2 = new Computer(manufacturer2, model2, price2); Computer computer3 = new Computer(manufacturer3, model3, price3); ComputerManager manager = new ComputerManager(); manager.AddComputer(computer); manager.AddComputer(computer2); manager.AddComputer(computer3); List <Computer> filteredComputers = (List <Computer>)(manager.GetComputersByManufacturer("IBM")); Assert.That(filteredComputers.Count == 2); Assert.That(filteredComputers[0].Manufacturer == "IBM"); Assert.That(filteredComputers[1].Manufacturer == "IBM"); Assert.That(filteredComputers[0].Model == "Xeon"); Assert.That(filteredComputers[1].Model == "SomeModel"); }
public void ComputerManagerAddMethodException() { ComputerManager compMan = new ComputerManager(); Computer comp = new Computer("DC", "A", (decimal)5.5); compMan.AddComputer(comp); Assert.That(() => compMan.AddComputer(comp), Throws.ArgumentException.With.Message.EqualTo("This computer already exists.")); }
public void AddSameComputerShouldThrowExc() { ComputerManager cm = new ComputerManager(); Computer computer = new Computer("Lenovo", "A50", 1500.50m); cm.AddComputer(computer); Assert.Throws <ArgumentException>(() => cm.AddComputer(computer)); }
public void Test1() { Computer computer = new Computer("name", "model", 1.23m); ComputerManager computerManager = new ComputerManager(); computerManager.AddComputer(computer); Assert.Throws <ArgumentException>(() => computerManager.AddComputer(computer)); }
public void Count_Should_Return_Correct_Value_With_Items() { var computerManager = new ComputerManager(); computerManager.AddComputer(new Computer("Asus", "Rog", 2000)); computerManager.AddComputer(new Computer("Asus1", "Rog1", 20020)); Assert.That(computerManager.Count, Is.EqualTo(2)); }
public void AddMethodShouldThrowExceptionIfNullOrDuplivateDataIsPassed() { var computerManager = new ComputerManager(); var computer = new Computer("Test", "Test", 10); Assert.Throws <ArgumentNullException>(() => computerManager.AddComputer(null)); computerManager.AddComputer(computer); Assert.Throws <ArgumentException>(() => computerManager.AddComputer(computer)); }
public void IsAddedCompIsExist_Should() { Computer comp = new Computer("Apple", "MacBook", 1500.50M); ComputerManager manager = new ComputerManager(); manager.AddComputer(comp); Assert.Throws <ArgumentException>(() => manager.AddComputer(comp)); }
public void Add_Method_Should_Throw_An_Exception_If_We_Try_To_Add_Existing_Computer() { var computerManager = new ComputerManager(); var computer = new Computer("Abcd", "dcba", 20000); computerManager.AddComputer(computer); Assert.Throws <ArgumentException>( () => computerManager.AddComputer(new Computer("Abcd", "dcba", 19)), "This computer is not existing."); }
public void GetComputerByManufacturerShouldThrowExcNull() { ComputerManager cm = new ComputerManager(); Computer computer = new Computer("Lenovo", "A50", 1500.50m); Computer computer2 = new Computer("Lenovooo", "A50000", 15000.50m); cm.AddComputer(computer); cm.AddComputer(computer2); Assert.Throws <ArgumentNullException>(() => cm.GetComputersByManufacturer(null)); }
public void GetComputerShouldThrowExcInavlidData() { ComputerManager cm = new ComputerManager(); Computer computer = new Computer("Lenovo", "A50", 1500.50m); Computer computer2 = new Computer("Lenovooo", "A50000", 15000.50m); cm.AddComputer(computer); cm.AddComputer(computer2); Assert.Throws <ArgumentException>(() => cm.GetComputer("Lenovo", "A")); }
public void AddComputer_ShouldThrowException_WhenInvalidArgumentsAreGiven() { //Arrange ComputerManager computerManager = new ComputerManager(); Computer testComputer = new Computer("Lenovo", "S 5000", 1000); // Act - Assert Assert.Throws <ArgumentNullException>(() => computerManager.AddComputer(null)); computerManager.AddComputer(testComputer); Assert.Throws <ArgumentException>(() => computerManager.AddComputer(testComputer)); }
public void ComputerManagerCount() { ComputerManager compMan = new ComputerManager(); Computer comp = new Computer("DC", "A", (decimal)5.5); Computer comptwo = new Computer("DC", "B", (decimal)5.5); compMan.AddComputer(comp); compMan.AddComputer(comptwo); Assert.That(compMan.Count, Is.EqualTo(2)); }
public void ComputerManager_ShouldThrow_WhenComputerIsAlreadyPresent(string manufacturer, string model, decimal price) { // arrange var computerManager = new ComputerManager(); var computer = new Computer(manufacturer, model, price); // act computerManager.AddComputer(computer); // assert Assert.Throws <ArgumentException>(() => computerManager.AddComputer(computer)); }
public void Test15() { Computer computer = new Computer("name", "model", 1.23m); Computer computer1 = new Computer("name1", "model1", 1.231m); ComputerManager computerManager = new ComputerManager(); computerManager.AddComputer(computer); computerManager.AddComputer(computer1); computerManager.RemoveComputer("name", "model"); Assert.AreEqual(1, computerManager.Computers.Count); }
public void AddShldThrException() { ComputerManager manager = new ComputerManager(); Computer computer = new Computer("BG", "Lenovo", 15); manager.AddComputer(computer); Assert.Throws <ArgumentException>(() => manager.AddComputer(computer)); Assert.Throws <ArgumentNullException>(() => manager.AddComputer(null)); }
public void GetComputersByManufacturerShouldWorkCorrectly() { ComputerManager computerManager = new ComputerManager(); computerManager.AddComputer(this.defaultComputer); computerManager.AddComputer(new Computer("Asus", "NotePad", 1500.00M)); var collection = computerManager.GetComputersByManufacturer("Asus").ToList(); int expectedCount = 2; Assert.That(collection.Count, Is.EqualTo(expectedCount)); }
public void AddingExistingComputerShouldThrowException() { var manager = new ComputerManager(); var computer = new Computer("HP", "HP", 10); Assert.Throws <ArgumentNullException>(() => manager.AddComputer(null)); manager.AddComputer(computer); Assert.Throws <ArgumentException>(() => manager.AddComputer(computer)); }
public void GetComputerShouldWork() { ComputerManager cm = new ComputerManager(); Computer computer = new Computer("Lenovo", "A50", 1500.50m); Computer computer2 = new Computer("Lenovooo", "A50000", 15000.50m); cm.AddComputer(computer); cm.AddComputer(computer2); var result = cm.GetComputer("Lenovo", "A50"); Assert.AreEqual(computer, result); }
public void GetComputerByManufacturerShouldReturnZero() { ComputerManager cm = new ComputerManager(); Computer computer = new Computer("Lenovo", "A50", 1500.50m); Computer computer2 = new Computer("Lenovo", "A50000", 15000.50m); cm.AddComputer(computer); cm.AddComputer(computer2); var collection = cm.GetComputersByManufacturer("Boza"); Assert.AreEqual(collection.Count, 0); }
public void RemoveComputerShouldWork() { ComputerManager cm = new ComputerManager(); Computer computer = new Computer("Lenovo", "A50", 1500.50m); Computer computer2 = new Computer("Lenovooo", "A50000", 15000.50m); cm.AddComputer(computer); cm.AddComputer(computer2); cm.RemoveComputer("Lenovo", "A50"); Assert.AreEqual(1, cm.Count); }
public void MethodAddComputerShouldThrowExceptionIfComputerAlreadyExists() { //Arrange ComputerManager computerManager = new ComputerManager(); Computer computer = new Computer("Manufacturer", "Model", 1000); //Act computerManager.AddComputer(computer); //Assert Assert.Throws <ArgumentException>(() => computerManager.AddComputer(computer)); }
public void ConstructorWorkingProperlyAndCounterToo() { ComputerManager manager = new ComputerManager(); Computer computer1 = new Computer("HP", "Nov", 1000m); Computer computer2 = new Computer("Acer", "Star", 600m); manager.AddComputer(computer1); manager.AddComputer(computer2); Assert.AreEqual(manager.Count, 2); Assert.AreEqual(manager.Computers.Count, 2); }
public void IsRemoveComputerChangeCount() { Computer comp = new Computer("Apple", "MacBook", 1550.50M); Computer comp1 = new Computer("Apple1", "MacBook1", 1500.50M); ComputerManager manager = new ComputerManager(); manager.AddComputer(comp); manager.AddComputer(comp1); manager.RemoveComputer("Apple", "MacBook"); Assert.AreEqual(1, manager.Count); }
public void REMOVEComputerShouldWorkAsExpected() { ComputerManager manager = new ComputerManager(); Computer computer1 = new Computer("HP", "HP", 1000); Computer computer2 = new Computer("Acer", "Acer", 100); manager.AddComputer(computer1); manager.AddComputer(computer2); var computertoremove = manager.RemoveComputer("Acer", "Acer"); Assert.AreEqual(computer2, computertoremove); Assert.AreEqual(1, manager.Computers.Count); }
public void MethodShouldThrowExceptionWhenManufacturerAndModelExists() { Computer computer = new Computer("IBM", "Xeon", 1500m); Computer computer2 = new Computer("IBM", "Xeon", 2500m); ComputerManager manager = new ComputerManager(); manager.AddComputer(computer); Assert.Throws <ArgumentException>(() => { manager.AddComputer(computer2); }); }
public void Get_Computers_By_Manufacturer_Method_Should_Return_Empty_Collection() { var computerManager = new ComputerManager(); computerManager.AddComputer(new Computer("1", "1", 20000)); computerManager.AddComputer(new Computer("2", "2", 100)); computerManager.AddComputer(new Computer("2", "3", 200)); computerManager.AddComputer(new Computer("2", "4", 300)); var computers = computerManager .GetComputersByManufacturer("51") .ToList(); Assert.IsEmpty(computers); Assert.That(computers.Count, Is.EqualTo(0)); }
public void Remove_Method_Should_Remove_Correctly() { var computerManager = new ComputerManager(); computerManager.AddComputer(new Computer("1", "1", 20000)); computerManager.AddComputer(new Computer("2", "2", 200000)); var computer = computerManager.RemoveComputer("1", "1"); Assert.That(computerManager.Computers.Count, Is.EqualTo(1)); Assert.That(computerManager.Count, Is.EqualTo(1)); Assert.That(computer.Manufacturer, Is.EqualTo("1")); Assert.That(computer.Model, Is.EqualTo("1")); Assert.That(computer.Price, Is.EqualTo(20000)); }
public void ComputerManagerGetCollectionMethodReturn() { ComputerManager compMan = new ComputerManager(); Computer comp = new Computer("DC", "A", (decimal)5.5); Computer compTwo = new Computer("DC", "B", (decimal)5.5); compMan.AddComputer(comp); compMan.AddComputer(compTwo); List <Computer> comps = new List <Computer>(); comps.Add(comp); comps.Add(compTwo); ICollection <Computer> compsReturned = compMan.GetComputersByManufacturer("DC"); Assert.That(compsReturned, Is.EqualTo(comps)); }
public void IsAddedCompIsNull_Should() { Computer comp = null; ComputerManager manager = new ComputerManager(); Assert.Throws <ArgumentNullException>(() => manager.AddComputer(comp)); }