예제 #1
0
        public void testInit()
        {
            NewAudi = new SUT.Auto()
            {
                VehicleIdentificationNumber = "07xxxxxxxxxxxxxxx", Year = "2020", Make = "Audi", Model = "A4", LocationOnLot = "B5"
            };
            cars = new List <SUT.Auto>()
            {
                new SUT.Auto {
                    VehicleIdentificationNumber = "01xxxxxxxxxxxxxxx", Year = "2008", Make = "Cadillac", Model = "CTS-V", LocationOnLot = "A5"
                },
                new SUT.Auto {
                    VehicleIdentificationNumber = "02xxxxxxxxxxxxxxx", Year = "1964", Make = "Dodge", Model = "Dart", LocationOnLot = "F3"
                },
                new SUT.Auto {
                    VehicleIdentificationNumber = "03xxxxxxxxxxxxxxx", Year = "1963", Make = "Cadillac", Model = "Fleetwood", LocationOnLot = "A23"
                },
                new SUT.Auto {
                    VehicleIdentificationNumber = "04xxxxxxxxxxxxxxx", Year = "1995", Make = "Hummer", Model = "H1 (Gas)", LocationOnLot = "C7"
                },
                new SUT.Auto {
                    VehicleIdentificationNumber = "05xxxxxxxxxxxxxxx", Year = "1958", Make = "Triumph", Model = "TR3", LocationOnLot = "A1"
                },
                new SUT.Auto {
                    VehicleIdentificationNumber = "06xxxxxxxxxxxxxxx", Year = "1968", Make = "Triumph", Model = "TR5", LocationOnLot = "A2"
                }
            };

            mock = new Mock <SUT.IAutoDBAccess>();
            mock.Setup(x => x.LoadLot()).Returns(cars);
            mock.Setup(x => x.SaveLot(cars)).Returns(true);
            autoControl = new SUT.AutoControl(mock.Object);
        }
예제 #2
0
 public void testClean()
 {
     NewAudi     = null;
     mock        = null;
     autoControl = null;
     cars        = null;
 }
예제 #3
0
        public void ThrowInvalidVINException_whentheVINisnotexactly17characterslong()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myInventory = new Mock <SUT.IAutoDBAccess>();
            var carAdded = new List <SUT.Auto>();

            carAdded.Add(new SUT.Auto
            {
                VehicleIdentificationNumber = "08xxxxxxxxxxxxxxxxx",
                Make          = "Doudge",
                Year          = "1968",
                Model         = "Dart",
                LocationOnLot = "C7"
            });
            myInventory.Setup(x => x.LoadLot()).Returns(AutoListTest());
            myInventory.Setup(x => x.SaveLot(It.IsAny <List <SUT.Auto> >())).Returns(true);

            //Act
            var findCar = new SUT.AutoControl(myInventory.Object);

            //Assert

            Assert.ThrowsException <InvalidVINException>(() => findCar.AddCar(carAdded[0]));
        }
예제 #4
0
        public void ThrowDuplicateVINException_WhencaronthelotwiththenewautosVIN()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myInventory = new Mock <SUT.IAutoDBAccess>();
            var carAdded = new List <SUT.Auto>();

            carAdded.Add(new SUT.Auto
            {
                VehicleIdentificationNumber = "03xxxxxxxxxxxxxxx",
                Make          = "Cadillac",
                Year          = "1963",
                Model         = "Fleetwood",
                LocationOnLot = "A23"
            });
            myInventory.Setup(x => x.LoadLot()).Returns(AutoListTest());
            myInventory.Setup(x => x.SaveLot(It.IsAny <List <SUT.Auto> >())).Returns(true);

            //Act
            var findCar = new SUT.AutoControl(myInventory.Object);



            //Assert && Act

            Assert.ThrowsException <DuplicateVINException>(() => findCar.AddCar(carAdded[0]));
        }
예제 #5
0
        public void ReturnProperluUpdate_WhenTheAddSuceceed()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myInventory = new Mock <SUT.IAutoDBAccess>();
            var carAdded = new List <SUT.Auto>();

            carAdded.Add(new SUT.Auto
            {
                VehicleIdentificationNumber = "08xxxxxxxxxxxxxxx",
                Make          = "Doudge",
                Year          = "1968",
                Model         = "Dart",
                LocationOnLot = "F9"
            });
            myInventory.Setup(x => x.LoadLot()).Returns(AutoListTest());
            myInventory.Setup(x => x.SaveLot(It.IsAny <List <SUT.Auto> >())).Returns(true);
            var findCar = new SUT.AutoControl(myInventory.Object);

            //Act
            var result = findCar.AddCar(carAdded[0]);

            //Assert

            Assert.AreEqual(7, result.Count());
        }
예제 #6
0
 public void testClean()
 {
     DuplicateCar     = null;
     NewAudi          = null;
     NewCarSameLot    = null;
     NewCarInvalidVin = null;
     mock             = null;
     autoControl      = null;
     cars             = null;
 }
예제 #7
0
        public void ThrowVinNOtFoundExcepction_WhenRequestedCarIsNotFound()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myInventory = new Mock <SUT.IAutoDBAccess>();

            myInventory.Setup(x => x.LoadLot()).Returns(AutoListTest());

            //Act
            var findCar = new SUT.AutoControl(myInventory.Object);

            // Assert
            Assert.ThrowsException <VINNotFoundException>(() => findCar.FindCar("07xxxxxxxxxxxxxxx"));
        }
예제 #8
0
        public void ReturnInstance_WhenRequestedCarIsFound()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myMockDBA = new Mock <SUT.IAutoDBAccess>();

            myMockDBA.Setup(x => x.LoadLot()).Returns(AutoListTest());
            var myFindCar = new SUT.AutoControl(myMockDBA.Object);

            //Act
            var result = myFindCar.FindCar("06xxxxxxxxxxxxxxx");

            //Assert

            Assert.AreEqual("06xxxxxxxxxxxxxxx", result.VehicleIdentificationNumber);
        }
예제 #9
0
        public void ReturnCorrectInstanceOf0_WhenLookingForAudiMake()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myInventory = new Mock <SUT.IAutoDBAccess>();

            myInventory.Setup(x => x.LoadLot()).Returns(AutoListTest());
            var findCar = new SUT.AutoControl(myInventory.Object);

            //Act
            var result = findCar.FindCarsByMake("Audi");

            //Assert

            Assert.IsTrue(result.Count.Equals(0));
        }
예제 #10
0
        public void ReturnCollection_WhenCarIsRemoved()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myInventory = new Mock <SUT.IAutoDBAccess>();
            var carAdded = new List <SUT.Auto>();

            myInventory.Setup(x => x.LoadLot()).Returns(AutoListTest());
            myInventory.Setup(x => x.SaveLot(It.IsAny <List <SUT.Auto> >())).Returns(true);
            var findCar = new SUT.AutoControl(myInventory.Object);

            //Act
            var result = findCar.RemoveCar("01xxxxxxxxxxxxxxx");

            //Assert

            Assert.AreEqual(5, result.Count());
        }
예제 #11
0
        public void VINNotFoundException_WhenTheCartobeRemovedIsNotOntheLot()
        {
            //Arrange

            Mock <SUT.IAutoDBAccess> myInventory = new Mock <SUT.IAutoDBAccess>();
            var carAdded = new List <SUT.Auto>();

            myInventory.Setup(x => x.LoadLot()).Returns(AutoListTest());
            myInventory.Setup(x => x.SaveLot(It.IsAny <List <SUT.Auto> >())).Returns(true);

            //Act
            var findCar = new SUT.AutoControl(myInventory.Object);



            //Assert

            Assert.ThrowsException <VINNotFoundException>(() => findCar.RemoveCar("09xxxxxxxxxxxxxxx"));
        }