예제 #1
0
        public void RemoveComputers_Test()
        {
            Computer computer = new Computer("Asus", "RX-200", 1000);

            computersManager.AddComputer(computer);
            Assert.That(computersManager.RemoveComputer("Asus", "RX-200"), Is.EqualTo(computer));
        }
 public void RemoveComputer_ShouldThrowExeption_WhenComputerIsNull()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         manager.RemoveComputer(computer1.Manufacturer, computer1.Model);
     });
 }
예제 #3
0
        public void WhenRemoveComputer_ShouldSetThatComputerIsRemoved()
        {
            computerManager.AddComputer(computer);
            computerManager.RemoveComputer(computer.Manufacturer, computer.Model);

            Assert.That(computerManager.Count, Is.EqualTo(0));
        }
예제 #4
0
        public void RemoveComputer_ShouldWorksCorrectly()
        {
            computerManager.AddComputer(new Computer("HP", "Laptop", 1200.0m));
            computerManager.RemoveComputer("HP", "Laptop");

            Assert.That(computerManager.Count, Is.EqualTo(0));
        }
예제 #5
0
        public void RemoveComputer_ShouldRemoveComputer()
        {
            Computer computer = new Computer("Acer", "predator", 3000);

            computerManager.AddComputer(computer);
            Assert.That(computerManager.RemoveComputer("Acer", "predator"), Is.EqualTo(computer));
            Assert.That(computerManager.Count, Is.EqualTo(0));
        }
예제 #6
0
        public void RemoveCompTest()
        {
            Computer computer = new Computer("Asus", "gamer", 1000);

            computers.AddComputer(computer);

            Assert.That(computers.RemoveComputer("Asus", "gamer"), Is.EqualTo(computer));
        }
 public void RemoveComputer_WhenRemoveNotExistingComputer()
 {
     computerManager.AddComputer(computer);
     Assert.Throws <ArgumentException>(() =>
     {
         computerManager.RemoveComputer("Panasonic", "380");
     });
 }
예제 #8
0
        public void RemovingPCShouldReturnPC()
        {
            this.pcMan.AddComputer(this.computer);

            Computer actual = pcMan.RemoveComputer("Test", "TestModel");

            Assert.AreEqual(this.computer, actual);
        }
예제 #9
0
        public void RemoveComputerShouldWorkAsExpected()
        {
            pcMngr.AddComputer(pc);

            pcMngr.RemoveComputer("Dell", "Vostro");

            Assert.AreEqual(0, pcMngr.Count);
        }
 public void RemoveCompDecreasesCountByOne()
 {
     manager.AddComputer(new Computer("M", "No", 900));
     manager.AddComputer(new Computer("L", "S", 9000));
     Assert.AreEqual(2, manager.Computers.Count);
     manager.RemoveComputer("L", "S");
     Assert.AreEqual(1, manager.Computers.Count);
 }
예제 #11
0
        public void RemoveComputer_ShouldRemoveComputerFromCollection()
        {
            manager.AddComputer(new Computer("Acer", "Aspire", 12345M));
            manager.AddComputer(new Computer("Acer", "Nitro", 1234665M));

            manager.RemoveComputer("Acer", "Nitro");

            Assert.That(manager.Count == 1);
        }
예제 #12
0
        public void RemoveComputerWorksCorrectly()
        {
            manager.AddComputer(computerOne);
            manager.AddComputer(computerTwo);
            var removed       = manager.RemoveComputer(computerOne.Manufacturer, computerOne.Model);
            var expectedCount = 1;

            Assert.That(manager.Count, Is.EqualTo(expectedCount));
            Assert.That(removed, Is.EqualTo((computerOne)));
        }
        public void RemovingExistingComputer_WorksCorrectly()
        {
            manager.AddComputer(first);
            Computer computer
                = manager.RemoveComputer(first.Manufacturer, first.Model);

            Assert.AreEqual(first.Manufacturer, computer.Manufacturer);
            Assert.AreEqual(first.Model, computer.Model);
            Assert.AreEqual(manager.Count, 0);
        }
        public void RemoveComputerShouldThrowException()
        {
            var computerManager = new ComputerManager();
            var computer        = new Computer("Test", "Test", 10);

            computerManager.AddComputer(computer);

            Assert.Throws <ArgumentNullException>(() => computerManager.RemoveComputer(null, "Test"));
            Assert.Throws <ArgumentNullException>(() => computerManager.RemoveComputer("Test", null));
            Assert.Throws <ArgumentException>(() => computerManager.RemoveComputer("wow", "wow"));
        }
예제 #15
0
        public void RemoveComputer_ShouldThrow_WhenComputerDataIsInvalid(string manufacturer, string model, decimal price)
        {
            // arrange
            var computerManager = new ComputerManager();
            var computer        = new Computer(manufacturer, model, price);

            // act, assert
            computerManager.AddComputer(computer);
            Assert.Throws <ArgumentNullException>(() => computerManager.RemoveComputer(null, "nonexistent"));
            Assert.Throws <ArgumentNullException>(() => computerManager.RemoveComputer("another", null));
        }
예제 #16
0
        public void RemoveComputer_Success()
        {
            Computer computerRemove = new Computer(manufacture, model, price);

            computerManager.AddComputer(computerRemove);
            Computer computer2 = new Computer("Laptop", "Hp", 2000);

            computerManager.AddComputer(computer2);
            Assert.That(computerManager.Computers.Count, Is.EqualTo(2));
            computerManager.RemoveComputer(manufacture, model);
            Assert.That(computerManager.Computers.Count, Is.EqualTo(1));
        }
예제 #17
0
        public void RemoveComputer_Should_Remove()
        {
            cm.AddComputer(twoThousand);
            cm.AddComputer(threeThousand);

            cm.RemoveComputer("Asus", "ROG2000");
            cm.RemoveComputer("Asus", "ROG3000");

            int expectedCount = 0;

            Assert.AreEqual(expectedCount, cm.Count);
        }
예제 #18
0
        public void RemoveCompShouldThrowException()
        {
            ComputerManager manager = new ComputerManager();

            Computer computer = new Computer("BG", "Lenovo", 15);



            Assert.Throws <ArgumentNullException>(() => manager.RemoveComputer("DJONI", null));
            Assert.Throws <ArgumentNullException>(() => manager.RemoveComputer(null, "DJONI"));

            Assert.Throws <ArgumentException>(() => manager.RemoveComputer("ZaZA", "bOBI"));
        }
        public void Page_Load(object sender, EventArgs e)
        {
            var computerName = Request.QueryString ["ComputerName"];

            var resultMessage = "";

            if (String.IsNullOrEmpty(computerName))
            {
                resultMessage = ("No computer name specified in the query string.");
                Response.Redirect("Computers.aspx?Result=" + resultMessage);
            }
            var indexDirectory = Path.GetFullPath(WebConfigurationManager.AppSettings ["IndexDirectory"]);

            var computersDirectory = Path.GetFullPath(WebConfigurationManager.AppSettings ["ComputersDirectory"]);

            var manager = new ComputerManager(indexDirectory, computersDirectory);

            var result = manager.RemoveComputer(computerName);

            var postFixQueryString = "";

            if (result.IsSuccess)
            {
                resultMessage = "Computer '" + computerName + "' was removed successfully!";
            }
            else
            {
                if (result.Error == ComputerActionError.NotFound)
                {
                    resultMessage = "Computer '" + computerName + "' wasn't found.";
                }
                postFixQueryString = "&IsSuccess=false";
            }
            Response.Redirect("Computers.aspx?Result=" + (resultMessage).Replace(" ", "+") + postFixQueryString);
        }
예제 #20
0
        public void RemoveComputer()
        {
            Computer computer = new Computer("HP", "Device200", 700);

            this.computerManager.AddComputer(computer);

            Assert.AreEqual(computer, computerManager.RemoveComputer("HP", "Device200"));
        }
예제 #21
0
        public void RemoveComputer_removes()
        {
            computerManager.AddComputer(computer);

            computerManager.RemoveComputer(computer.Manufacturer, computer.Model);

            Assert.That(computerManager.Computers.Any(c => c.Manufacturer == computer.Manufacturer), Is.False);
        }
        public void Remove_Method_Should_Throw_An_Exception_If_The_Manufacturer_Is_Null()
        {
            var computerManager = new ComputerManager();

            Assert.Throws <ArgumentNullException>(
                () => computerManager.RemoveComputer(null, "10"),
                "Value is not null.");
        }
예제 #23
0
        public void RemoveComputerShouldThrowException()
        {
            ComputerManager manager   = new ComputerManager();
            Computer        computer1 = new Computer("HP", "HP", 1000);

            manager.AddComputer(computer1);


            Assert.Throws <ArgumentNullException>(()
                                                  => manager.RemoveComputer("HP", null));

            Assert.Throws <ArgumentNullException>(()
                                                  => manager.RemoveComputer(null, "HP"));

            Assert.Throws <ArgumentException>(()
                                              => manager.RemoveComputer("Acer", "Acer"));
        }
예제 #24
0
        public void RemoveCompThrowException()
        {
            Computer computer = new Computer("Asus", "gamer", 1000);

            computerManager.AddComputer(computer);

            Assert.Throws <ArgumentException>(() => computerManager.RemoveComputer("Hp", "gamer"));
        }
예제 #25
0
        public void Test11()
        {
            Computer        computer        = new Computer("asd", "asd", 12.3m);
            ComputerManager computerManager = new ComputerManager();

            computerManager.AddComputer(computer);
            computerManager.RemoveComputer("asd", "asd");
            Assert.AreEqual(computerManager.Count, 0);
        }
        public void MethodRemoveComputerShouldThrowExceptionIfCollectionIsEmpty()
        {
            //Arrange
            ComputerManager computerManager = new ComputerManager();

            //Act - Assert
            Assert.Throws <ArgumentException>(()
                                              => computerManager.RemoveComputer("Manufacturer", "Model"));
        }
예제 #27
0
        public void IsRemoveComputerReturnCorrectComp()
        {
            Computer comp = new Computer("Apple", "MacBook", 1500.50M);

            ComputerManager manager = new ComputerManager();

            manager.AddComputer(comp);

            Assert.AreEqual(comp, manager.RemoveComputer("Apple", "MacBook"));
        }
예제 #28
0
        public void ComputerManagerRemoveMethod()
        {
            ComputerManager compMan = new ComputerManager();
            Computer        comp    = new Computer("DC", "A", (decimal)5.5);

            compMan.AddComputer(comp);
            Computer compRemoved = compMan.RemoveComputer("DC", "A");

            Assert.That(compRemoved, Is.EqualTo(compRemoved));
        }
예제 #29
0
        public void ComputerManagerGetMethodEception()
        {
            ComputerManager compMan = new ComputerManager();
            Computer        comp    = new Computer("DC", "A", (decimal)5.5);

            compMan.AddComputer(comp);


            Assert.That(() => compMan.RemoveComputer("DC", "B"), Throws.ArgumentException.With.Message.EqualTo("There is no computer with this manufacturer and model."));
        }
예제 #30
0
        public void Test14()
        {
            Computer        computer        = new Computer("name", "model", 1.23m);
            ComputerManager computerManager = new ComputerManager();

            computerManager.AddComputer(computer);


            Assert.AreEqual(computer, computerManager.RemoveComputer("name", "model"));
        }