Exemplo n.º 1
0
        public void WhenUpdatingBrandWithInvalidValues_ExceptionThrwon(string id, string name, string country, string founded, string revenue)
        {
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);
            Assert.Throws(typeof(InvalidParameterException), () => logic.UpdateBrandLogic(id, name, country, founded, revenue));
        }
Exemplo n.º 2
0
        public void WhenCreatingExtra_WithBadParameters_ExceptionIsThrown(string categoryName, string extraName, string color, string price, string reusable)
        {
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);
            Assert.Throws(typeof(InvalidParameterException), () => logic.CreateExtraLogic(categoryName, extraName, color, price, reusable));
        }
Exemplo n.º 3
0
        public void WhenCreatingModel_WithBadParameters_ExceptionThrown(string id, string name, string startDate, string engineSize, string horsePower, string price)
        {
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);
            Assert.Throws(typeof(InvalidParameterException), () => logic.CreateModelLogic(id, name, startDate, engineSize, horsePower, price));
        }
Exemplo n.º 4
0
        public void WhenCreatingBrand_WithBadParameters_ExceptionThrown(string name, string country, string url, string date, string revenue)
        {
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);
            Assert.Throws(typeof(InvalidParameterException), () => logic.CreateBrandLogic(name, country, url, date, revenue));
        }
Exemplo n.º 5
0
        public void WhenDeletingExtraWithInvalidId_ExceptionIsThrown(string selection)
        {
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);

            Assert.Throws(typeof(InvalidParameterException), () => logic.DeleteExtra(selection));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Checks if repository was called once
        /// </summary>
        /// <param name="selection">id of the extra</param>
        public void WhenDeletingExtra_RepositoryIsCalled(string selection)
        {
            CarLogic logic = new CarLogic();

            // this.mockedRepository.Setup(m => m.DeleteModelRepo(It.IsAny<car_models>()));
            logic.SetRepositoryInterface(this.mockedRepository.Object);
            logic.DeleteModel(selection);
            this.mockedRepository.Verify(m => m.DeleteExtraRepo(It.IsAny <extra>()), Times.Once);
        }
Exemplo n.º 7
0
        public void WhenGettingExtraConnections_GetsExtraConnections()
        {
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);

            var result = logic.ListConnectionLogic();

            Assert.That(result.Count(), Is.EqualTo(3));
            Assert.That(result.SingleOrDefault(x => x.id == 3), Is.Not.Null);
        }
Exemplo n.º 8
0
        public void WhenDeletingBrand_RepositoryIsCalled(string selection)
        {
            // Arrange
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);

            // Act
            logic.DeleteBrand(selection);

            // Assert (Verify)
            this.mockedRepository.Verify(m => m.DeleteBrandRepo(It.IsAny <car_brands>()), Times.AtLeastOnce);
        }
Exemplo n.º 9
0
        public void WhenDeletingBrandWithInvalidId_ExceptionIsThrown(string selection)
        {
            // Arrange
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);

            // Act, Assert
            Assert.Throws(typeof(InvalidParameterException), () => logic.DeleteBrand(selection));

            this.mockedRepository.Verify(
                m => m.DeleteBrandRepo(It.IsAny <car_brands>()), Times.Never);
        }
Exemplo n.º 10
0
        public void WhenGettingExtrasFromDb_GetsExtras()
        {
            // Mock
            CarLogic logic = new CarLogic();

            logic.SetRepositoryInterface(this.mockedRepository.Object);

            // Act
            var result = logic.ListExtraLogic();

            // Assert
            Assert.That(result.Count(), Is.EqualTo(3));
            Assert.That(result.SingleOrDefault(x => x.name == "turbo"), Is.Not.Null);
        }