public void GetComputersByManufacturer_throws()
 {
     Assert.That(() =>
     {
         computerManager.GetComputersByManufacturer(null);
     }, Throws.ArgumentNullException);
 }
Example #2
0
        public void GetComputerByManufacturer()
        {
            Computer computer = new Computer("Asus", "gamer", 1000);

            computers.AddComputer(computer);
            var result = computers.GetComputersByManufacturer("Asus");

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.AreEqual(result, computers.Computers);
        }
        public void GetComputerByManufacturerWorksCorrectly()
        {
            compManager.AddComputer(new Computer("TestManufacturer", "TestModel", 100));
            compManager.AddComputer(new Computer("TestManufacturer", "testModel123", 100));
            compManager.AddComputer(new Computer("NotTest", "testModel123", 100));

            var comp = compManager.GetComputersByManufacturer("TestManufacturer");

            Assert.That(comp.Count, Is.EqualTo(2));
        }
Example #4
0
        public void GetGetComputersByManufacturer_Should_Throw_NullValue()
        {
            cm.AddComputer(twoThousand);
            cm.AddComputer(threeThousand);
            cm.AddComputer(fourThousand);

            Assert.Throws <ArgumentNullException>(() =>
            {
                cm.GetComputersByManufacturer(null);
            });
        }
Example #5
0
        public void GetComputersByManufacturer_ShouldReturnEmptyCollectionWhenNoComputersWithGivenManufacturer()
        {
            computerManager.AddComputer(computer);
            var comp = new Computer("Asus", "K54HR", 1000m);

            computerManager.AddComputer(comp);
            var otherComp = new Computer("IBM", "model", 1300m);

            computerManager.AddComputer(otherComp);

            var collection = computerManager.GetComputersByManufacturer("Toshiba");

            CollectionAssert.IsEmpty(collection);
        }
Example #6
0
        public void GetComputersByManufacturer()
        {
            Computer computer1 = new Computer("HP", "Device200", 700);
            Computer computer2 = new Computer("HP", "D320", 700);
            Computer computer3 = new Computer("Lenovo", "D320", 700);

            this.computerManager.AddComputer(computer1);
            this.computerManager.AddComputer(computer2);
            this.computerManager.AddComputer(computer3);

            ICollection <Computer> expectedComputers =
                this.computerManager.Computers.Where(x => x.Manufacturer == "HP").ToList();

            Assert.AreEqual(expectedComputers, computerManager.GetComputersByManufacturer("HP"));
        }
        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 GetComputersByManufacturerIsWorkingProperly()
        {
            Computer computer  = new Computer("Dawe", "Turbo", 44);
            Computer computer3 = new Computer("Op", "Daas", 55);

            cm.AddComputer(computer);
            cm.AddComputer(computer3);

            ICollection <Computer> expected = new List <Computer>()
            {
                computer3
            };
            var actual = cm.GetComputersByManufacturer("Op");

            CollectionAssert.AreEqual(expected, actual);
        }
 public void GetComputerByManifacturer_ThrowsException_WhenManufacturerIsNull()
 {
     Exception ex = Assert.Throws <ArgumentNullException>(() =>
     {
         computerManager.GetComputersByManufacturer(null);
     }, "Can not be null!");
 }
Example #10
0
        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");
        }
Example #11
0
        public void Test5()
        {
            Computer        computer        = new Computer("name", "model", 1.23m);
            ComputerManager computerManager = new ComputerManager();


            Assert.Throws <ArgumentNullException>(() => computerManager.GetComputersByManufacturer(null));
        }
        public void Get_Computers_By_Manufacturer_Method_Should_Throw_An_Exception_If_The_Manufacturer_Is_Null()
        {
            var computerManager = new ComputerManager();

            Assert.Throws <ArgumentNullException>(
                () => computerManager.GetComputersByManufacturer(null),
                "Value is not null.");
        }
        public void GetComputersByManufacturer_ShouldThrowException_WhenInvalidArgumentsAreGiven()
        {
            //Arrange
            ComputerManager computerManager = new ComputerManager();

            // Act - Assert
            Assert.Throws <ArgumentNullException>(() => computerManager.GetComputersByManufacturer(null));
        }
        public void Test_GetComputersByManufactorerReturnsEmptyCollection()
        {
            computerMenager.AddComputer(computer);
            computerMenager.AddComputer(new Computer("Hp", "SomeOtherModel", 2300M));

            var emptyCollection = new List <Computer>();

            CollectionAssert.AreEqual(emptyCollection, computerMenager.GetComputersByManufacturer("Asus"));
        }
        public void GetComputerManufacturerShouldWorkAsExpected()
        {
            var computerManager = new ComputerManager();
            var computer        = new Computer("Test", "Test1", 10);
            var computer2       = new Computer("Test", "Test2", 10);
            var computer3       = new Computer("Test3", "Test3", 10);

            computerManager.AddComputer(computer);
            computerManager.AddComputer(computer2);
            computerManager.AddComputer(computer3);

            var computerFromComputerManager = computerManager.GetComputersByManufacturer("Test");

            Assert.Throws <ArgumentNullException>(() => computerManager.GetComputersByManufacturer(null));
            CollectionAssert.Contains(computerFromComputerManager, computer);
            CollectionAssert.Contains(computerFromComputerManager, computer2);
            CollectionAssert.DoesNotContain(computerFromComputerManager, computer3);
        }
        public void GetComputerByManufacturer_EmptyColletion()
        {
            computerManager.AddComputer(computer);
            computerManager.AddComputer(new Computer("Hp", "SomeOtherModel", 550));

            var emptyColletion = new List <Computer>();

            CollectionAssert.AreEqual(emptyColletion, computerManager.GetComputersByManufacturer("Assus"));
        }
Example #17
0
        public void CheckIfGetComputersByManufacturerReturnsNullWhenNoComputerWithThisManufacturer()
        {
            computerManager.AddComputer(new Computer("Apple", "Mac1", 12.4m));
            computerManager.AddComputer(new Computer("Apple", "Mac2", 122.4m));
            computerManager.AddComputer(new Computer("Apple", "Mac3", 121.4m));
            var listByManufacturer = computerManager.GetComputersByManufacturer("Dell");

            Assert.AreEqual(listByManufacturer.Count, 0);
        }
Example #18
0
        public void GetComputersByManufacturerShouldReturnEmptyCollectionWhenNoMatchesFound()
        {
            ComputerManager computerManager = new ComputerManager();

            computerManager.AddComputer(this.computer);

            var collection = computerManager.GetComputersByManufacturer("Asus").ToList();

            CollectionAssert.IsEmpty(collection);
        }
Example #19
0
        public void GetComputersByManufacturer_ShouldThrow_WhenComputerDataIsInvalid(string manufacturer)
        {
            // arrange
            var computerManager = new ComputerManager();
            var computer        = new Computer(manufacturer, "ads", 123.40m);

            // act, assert
            computerManager.AddComputer(computer);
            Assert.Throws <ArgumentNullException>(() => computerManager.GetComputersByManufacturer(manufacturer));
        }
Example #20
0
        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));
        }
Example #21
0
        public void GetComputersByManufacturerCanNotBeNull()
        {
            Computer        comp    = new Computer("Apple", "MacBook", 1550.50M);
            ComputerManager manager = new ComputerManager();

            manager.AddComputer(comp);

            string man = null;

            Assert.Throws <ArgumentNullException>(() => manager.GetComputersByManufacturer(man));
        }
        public void SelectingComputersByManufacturer_WorksCorrectly()
        {
            manager.AddComputer(first);
            manager.AddComputer(second);
            manager.AddComputer(third);
            var selected = manager
                           .GetComputersByManufacturer(first.Manufacturer);

            Assert.AreEqual(selected.Count, 2);
            CollectionAssert.Contains(selected, first);
        }
        public void GetComputersByManufacturerShouldThrowExceptionWhenManufacturerIsNull()
        {
            ComputerManager computerManager = new ComputerManager();

            computerManager.AddComputer(this.defaultComputer);

            Assert.Throws <ArgumentNullException>(() =>
            {
                var collection = computerManager.GetComputersByManufacturer(null);
            });
        }
Example #24
0
        public void GetAllByManufacturerShouldReturnCorrectCollection()
        {
            Computer computer = new Computer("Asus", "gamer", 1000);

            computerManager.AddComputer(computer);
            computerManager.AddComputer(new Computer("Asus", "K210", 899.99m));
            computerManager.AddComputer(new Computer("Hp", "P34", 420));
            var collection = computerManager.GetComputersByManufacturer("Asus");

            Assert.That(collection.Count, Is.EqualTo(2));
        }
        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 GetComputersByManufacturer_ShouldReturnCollectionOfComputersWithSameManufacterur()
        {
            List <Computer> computers = new List <Computer>();

            computers.Add(computer1);

            manager.AddComputer(computer1);
            manager.AddComputer(computer2);
            var compManager = manager.GetComputersByManufacturer("Acer");

            Assert.AreEqual(compManager, computers);
        }
Example #27
0
        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 MethodGetComputersByManufacturerShouldThrowExceptionIfManufacturerIsNull()
        {
            //Arrange
            ComputerManager computerManager = new ComputerManager();
            Computer        computer        = new Computer("Manufacturer", "Model", 1000);

            //Act
            computerManager.AddComputer(computer);

            //Assert
            Assert.Throws <ArgumentNullException>(()
                                                  => computerManager.GetComputersByManufacturer(null));
        }
        public void MethodGetComputersByManufacturerShouldReturnEmtyCollectionIfThereAreNoSatisfyingCondition()
        {
            //Arrange
            ComputerManager computerManager = new ComputerManager();
            Computer        computer        = new Computer("Manufacturer", "Model", 1000);

            //Act
            computerManager.AddComputer(computer);
            ICollection <Computer> expectedResult = new List <Computer>();
            ICollection <Computer> actualResult   = computerManager.GetComputersByManufacturer("Manufacturer2");

            //Assert
            CollectionAssert.AreEqual(expectedResult, actualResult);
        }
Example #30
0
        public void GetComputersByManufacturer_ShouldReturn_WhenComputerDataIsValid(string manufacturer)
        {
            // arrange
            var computerManager = new ComputerManager();
            var computer        = new Computer(manufacturer, "ads", 123.40m);

            // act
            computerManager.AddComputer(computer);
            var compputersByManufacturer = computerManager.GetComputersByManufacturer(manufacturer);

            // assert
            Assert.NotNull(compputersByManufacturer);
            Assert.AreEqual(1, compputersByManufacturer.Count);
        }