public async Task GetAllOils_WithDummyData_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "MotorOilService GetAllOils() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.motorOilService = new MotorOilService(context);

            List <MotorOilServiceModel> actualResults = await this.motorOilService.GetAllOils().ToListAsync();

            List <MotorOilServiceModel> expectedResults = GetDummyData().To <MotorOilServiceModel>().ToList();

            for (int i = 0; i < expectedResults.Count; i++)
            {
                var expectedEntry = expectedResults[i];
                var actualEntry   = actualResults[i];

                Assert.True(expectedEntry.Model == actualEntry.Model, errorMessagePrefix + " " + "Model is not returned properly.");
                Assert.True(expectedEntry.Brand == actualEntry.Brand, errorMessagePrefix + " " + "Brand is not returned properly.");
                Assert.True(expectedEntry.Viscosity == actualEntry.Viscosity, errorMessagePrefix + " " + "Viscosity is not returned properly.");
                Assert.True(expectedEntry.Status == actualEntry.Status, errorMessagePrefix + " " + "Status is not returned properly.");
                Assert.True(expectedEntry.Volume == actualEntry.Volume, errorMessagePrefix + " " + "Volume is not returned properly.");
                Assert.True(expectedEntry.Type == actualEntry.Type, errorMessagePrefix + " " + "Type is not returned properly.");
                Assert.True(expectedEntry.Description == actualEntry.Description, errorMessagePrefix + " " + "Description is not returned properly.");
                Assert.True(expectedEntry.Price == actualEntry.Price, errorMessagePrefix + " " + "Price is not returned properly.");
                Assert.True(expectedEntry.Picture == actualEntry.Picture, errorMessagePrefix + " " + "Picture is not returned properly.");
            }
        }
        public async Task EditWheelRim_WithCorrectData_ShouldEditProductCorrectly()
        {
            string errorMessagePrefix = "WheelRimService EditWheelRim() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.wheelRimService = new WheelRimService(context);

            WheelRimServiceModel expectedData = context.WheelRims.First().To <WheelRimServiceModel>();

            expectedData.Model            = "EdittedModelame";
            expectedData.Price            = 0.01M;
            expectedData.YearOfProduction = 1998;
            expectedData.Picture          = "Editted_Picture";

            await this.wheelRimService.EditWheelRim(expectedData);

            WheelRimServiceModel actualData = context.Tyres.First().To <WheelRimServiceModel>();

            Assert.True(actualData.Model == expectedData.Model, errorMessagePrefix + " " + "Model not editted properly.");
            Assert.True(actualData.Price == expectedData.Price, errorMessagePrefix + " " + "Price not editted properly.");
            Assert.True(actualData.YearOfProduction == expectedData.YearOfProduction, errorMessagePrefix + " " + "YearOfProduction not editted properly.");
            Assert.True(actualData.Picture == expectedData.Picture, errorMessagePrefix + " " + "Picture not editted properly.");
        }
        public async Task Create_WithCorrectData_ShouldSuccessfullyCreate()
        {
            string errorMessagePrefix = "WheelRimService Create() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.wheelRimService = new WheelRimService(context);

            WheelRimServiceModel testProduct = new WheelRimServiceModel
            {
                Model            = "Atom Ant",
                Brand            = "Palmer Tech",
                Material         = "atomsteel",
                Price            = 209.59M,
                YearOfProduction = 2018,
                Picture          = "src/pics/somethingfunny/atomant",
                Offset           = 205,
                PCD = "65",
                CentralLukeDiameter = 15,
                Status      = Models.Enums.AvailabilityStatus.InStock,
                Description = "Wield the power of Atom Ant!"
            };

            bool actualResult = await this.wheelRimService.Create(testProduct);

            Assert.True(actualResult, errorMessagePrefix);
        }
        public async Task GetWheelRimById_WithExistentId_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "WheelRimService GetWheelRimById() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.wheelRimService = new WheelRimService(context);

            WheelRimServiceModel expectedData = context.WheelRims.First().To <WheelRimServiceModel>();
            WheelRimServiceModel actualData   = this.wheelRimService.GetWheelRimById(expectedData.Id);

            Assert.True(expectedData.Model == actualData.Model, errorMessagePrefix + " " + "Model is not returned properly.");
            Assert.True(expectedData.Brand == actualData.Brand, errorMessagePrefix + " " + "Brand is not returned properly.");
            Assert.True(expectedData.PCD == actualData.PCD, errorMessagePrefix + " " + "PCD is not returned properly.");
            Assert.True(expectedData.Status == actualData.Status, errorMessagePrefix + " " + "Status is not returned properly.");
            Assert.True(expectedData.CentralLukeDiameter == actualData.CentralLukeDiameter, errorMessagePrefix + " " + "CentralLukeDiameter is not returned properly.");
            Assert.True(expectedData.Material == actualData.Material, errorMessagePrefix + " " + "Material is not returned properly.");
            Assert.True(expectedData.Description == actualData.Description, errorMessagePrefix + " " + "Description is not returned properly.");
            Assert.True(expectedData.Offset == actualData.Offset, errorMessagePrefix + " " + "Offset is not returned properly.");
            Assert.True(expectedData.YearOfProduction == actualData.YearOfProduction, errorMessagePrefix + " " + "YearOfProduction is not returned properly.");
            Assert.True(expectedData.Price == actualData.Price, errorMessagePrefix + " " + "Price is not returned properly.");
            Assert.True(expectedData.Picture == actualData.Picture, errorMessagePrefix + " " + "Picture is not returned properly.");
        }
        public async Task EditMotorOil_WithCorrectData_ShouldEditProductCorrectly()
        {
            string errorMessagePrefix = "MotorOilService EditMotorOil() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.motorOilService = new MotorOilService(context);

            MotorOilServiceModel expectedData = context.MotorOils.First().To <MotorOilServiceModel>();

            expectedData.Model   = "EdittedModelame";
            expectedData.Price   = 0.01M;
            expectedData.Volume  = 6;
            expectedData.Picture = "Editted_Picture";

            await this.motorOilService.EditMotorOil(expectedData);

            MotorOilServiceModel actualData = context.Tyres.First().To <MotorOilServiceModel>();

            Assert.True(actualData.Model == expectedData.Model, errorMessagePrefix + " " + "Model not editted properly.");
            Assert.True(actualData.Price == expectedData.Price, errorMessagePrefix + " " + "Price not editted properly.");
            Assert.True(actualData.Volume == expectedData.Volume, errorMessagePrefix + " " + "Volume not editted properly.");
            Assert.True(actualData.Picture == expectedData.Picture, errorMessagePrefix + " " + "Picture not editted properly.");
        }
        public async Task Create_WithCorrectData_ShouldSuccessfullyCreate()
        {
            string errorMessagePrefix = "MotorOilService Create() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.motorOilService = new MotorOilService(context);

            MotorOilServiceModel testProduct = new MotorOilServiceModel
            {
                Model       = "Atom Wym",
                Brand       = "Wym Tech",
                Viscosity   = "35awd",
                Price       = 209.59M,
                Type        = "unnatural",
                Picture     = "src/pics/somethingfunny/atomant",
                Volume      = 26,
                Status      = Models.Enums.AvailabilityStatus.OutOfStock,
                Description = "Wield the oil of Atom Wym!"
            };

            bool actualResult = await this.motorOilService.Create(testProduct);

            Assert.True(actualResult, errorMessagePrefix);
        }
Exemplo n.º 7
0
        public async Task GetAllTyres_WithDummyData_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "TyreService GetAllTyress() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.tyreService = new TyreService(context);

            List <TyreServiceModel> actualResults = await this.tyreService.GetAllTyres().ToListAsync();

            List <TyreServiceModel> expectedResults = GetDummyData().To <TyreServiceModel>().ToList();

            for (int i = 0; i < expectedResults.Count; i++)
            {
                var expectedEntry = expectedResults[i];
                var actualEntry   = actualResults[i];

                Assert.True(expectedEntry.Model == actualEntry.Model, errorMessagePrefix + " " + "Model is not returned properly.");
                Assert.True(expectedEntry.Brand == actualEntry.Brand, errorMessagePrefix + " " + "Brand is not returned properly.");
                Assert.True(expectedEntry.Type == actualEntry.Type, errorMessagePrefix + " " + "Type is not returned properly.");
                Assert.True(expectedEntry.Status == actualEntry.Status, errorMessagePrefix + " " + "Status is not returned properly.");
                Assert.True(expectedEntry.Diameter == actualEntry.Diameter, errorMessagePrefix + " " + "Diameter is not returned properly.");
                Assert.True(expectedEntry.Ratio == actualEntry.Ratio, errorMessagePrefix + " " + "Ratio is not returned properly.");
                Assert.True(expectedEntry.Description == actualEntry.Description, errorMessagePrefix + " " + "Description is not returned properly.");
                Assert.True(expectedEntry.Width == actualEntry.Width, errorMessagePrefix + " " + "Width is not returned properly.");
                Assert.True(expectedEntry.YearOfProduction == actualEntry.YearOfProduction, errorMessagePrefix + " " + "YearOfProduction is not returned properly.");
                Assert.True(expectedEntry.Price == actualEntry.Price, errorMessagePrefix + " " + "Price is not returned properly.");
                Assert.True(expectedEntry.Picture == actualEntry.Picture, errorMessagePrefix + " " + "Picture is not returned properly.");
            }
        }
Exemplo n.º 8
0
        public async Task Create_WithCorrectData_ShouldSuccessfullyCreate()
        {
            string errorMessagePrefix = "TyreService Create() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.tyreService = new TyreService(context);

            TyreServiceModel testProduct = new TyreServiceModel
            {
                Model            = "Giant Ant",
                Brand            = "Pym Tech",
                Type             = Models.Enums.SeasonType.AllSeasons,
                Price            = 189.59M,
                YearOfProduction = 2018,
                Picture          = "src/pics/giant/ant",
                Width            = 195,
                Ratio            = 65,
                Diameter         = 15,
                Status           = Models.Enums.AvailabilityStatus.OutOfStock,
                Description      = "Wield the power of Giant Ant!"
            };

            bool actualResult = await this.tyreService.Create(testProduct);

            Assert.True(actualResult, errorMessagePrefix);
        }
Exemplo n.º 9
0
        public async Task GetTyreById_WithExistentId_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "TyreService GetTyreById() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.tyreService = new TyreService(context);

            TyreServiceModel expectedData = context.Tyres.First().To <TyreServiceModel>();
            TyreServiceModel actualData   = this.tyreService.GetTyreById(expectedData.Id);

            Assert.True(expectedData.Model == actualData.Model, errorMessagePrefix + " " + "Model is not returned properly.");
            Assert.True(expectedData.Brand == actualData.Brand, errorMessagePrefix + " " + "Brand is not returned properly.");
            Assert.True(expectedData.Type == actualData.Type, errorMessagePrefix + " " + "Type is not returned properly.");
            Assert.True(expectedData.Status == actualData.Status, errorMessagePrefix + " " + "Status is not returned properly.");
            Assert.True(expectedData.Diameter == actualData.Diameter, errorMessagePrefix + " " + "Diameter is not returned properly.");
            Assert.True(expectedData.Ratio == actualData.Ratio, errorMessagePrefix + " " + "Ratio is not returned properly.");
            Assert.True(expectedData.Description == actualData.Description, errorMessagePrefix + " " + "Description is not returned properly.");
            Assert.True(expectedData.Width == actualData.Width, errorMessagePrefix + " " + "Width is not returned properly.");
            Assert.True(expectedData.YearOfProduction == actualData.YearOfProduction, errorMessagePrefix + " " + "YearOfProduction is not returned properly.");
            Assert.True(expectedData.Price == actualData.Price, errorMessagePrefix + " " + "Price is not returned properly.");
            Assert.True(expectedData.Picture == actualData.Picture, errorMessagePrefix + " " + "Picture is not returned properly.");
        }
Exemplo n.º 10
0
        public async Task GetWheelRimById_WithNonExistentId_ShouldReturnNull()
        {
            string errorMessagePrefix = "WheelRimService GetWheelRimById() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.wheelRimService = new WheelRimService(context);

            WheelRimServiceModel actualData = this.wheelRimService.GetWheelRimById("stamat");

            Assert.True(actualData == null, errorMessagePrefix);
        }
Exemplo n.º 11
0
        public async Task EditWheelRim_WithCorrectData_ShouldPassSuccessfully()
        {
            string errorMessagePrefix = "WheelRimService EditWheelRim() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.wheelRimService = new WheelRimService(context);

            WheelRimServiceModel expectedData = context.WheelRims.First().To <WheelRimServiceModel>();

            bool actualData = await this.wheelRimService.EditWheelRim(expectedData);

            Assert.True(actualData, errorMessagePrefix);
        }
Exemplo n.º 12
0
        public async Task EditMotorOil_WithNonExistentTyreId_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "MotorOilService EditMotorOil() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.motorOilService = new MotorOilService(context);

            MotorOilServiceModel expectedData = context.MotorOils.First().To <MotorOilServiceModel>();


            expectedData.Id      = "1";
            expectedData.Model   = "EdittedModelame";
            expectedData.Price   = 0.01M;
            expectedData.Volume  = 6;
            expectedData.Picture = "Editted_Picture";

            await Assert.ThrowsAsync <ArgumentNullException>(() => this.motorOilService.EditMotorOil(expectedData));
        }
Exemplo n.º 13
0
        public async Task GetMotorilId_WithExistentId_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "MotorOilService GetMotorOilById() method does not work properly.";

            var context = SntDbContextInMemoryFactory.InitializeContext();

            await SeedData(context);

            this.motorOilService = new MotorOilService(context);

            MotorOilServiceModel expectedData = context.MotorOils.First().To <MotorOilServiceModel>();
            MotorOilServiceModel actualData   = this.motorOilService.GetMotorOilById(expectedData.Id);

            Assert.True(expectedData.Model == actualData.Model, errorMessagePrefix + " " + "Model is not returned properly.");
            Assert.True(expectedData.Brand == actualData.Brand, errorMessagePrefix + " " + "Brand is not returned properly.");
            Assert.True(expectedData.Viscosity == actualData.Viscosity, errorMessagePrefix + " " + "Viscosity is not returned properly.");
            Assert.True(expectedData.Status == actualData.Status, errorMessagePrefix + " " + "Status is not returned properly.");
            Assert.True(expectedData.Volume == actualData.Volume, errorMessagePrefix + " " + "Volume is not returned properly.");
            Assert.True(expectedData.Type == actualData.Type, errorMessagePrefix + " " + "Type is not returned properly.");
            Assert.True(expectedData.Description == actualData.Description, errorMessagePrefix + " " + "Description is not returned properly.");
            Assert.True(expectedData.Price == actualData.Price, errorMessagePrefix + " " + "Price is not returned properly.");
            Assert.True(expectedData.Picture == actualData.Picture, errorMessagePrefix + " " + "Picture is not returned properly.");
        }