public void AdminController_AddManufacturer_Success()
        {
            Users user = new Users {
                Id = 1, UserName = "******"
            };
            var cancel = new CancellationToken();

            var addManufModel = new AdminModel {
                Manufacturer = adminModel.Manufacturer
            };

            var productService = new StoreProductService(_context);
            var userService    = new UserService(_context);
            var mockUserStore  = new Mock <IUserStore <Users> >();

            mockUserStore.Setup(u => u.CreateAsync(user, cancel));

            var manager = new UserManager <Users>(mockUserStore.Object, null, null, null, null, null, null, null, null);

            var Controller = new AdminController(productService, manager, userService, null);

            var addManufacturer  = Controller.AddManufacturer(addManufModel);
            var getManufacturers = productService.GetAllManufacturers();

            Assert.Equal("manufacturerName", getManufacturers.First().Name);
        }
Exemple #2
0
        public void AddManufacturer_Returns_JsonResult_Added_Succesfully()
        {
            Users user = new Users {
                Id = 1, UserName = "******"
            };
            var cancel = new CancellationToken();

            var manufac = new Manufacturer {
                Id = 1, Name = "manuf"
            };
            var adminModel = new AdminModel {
                Manufacturer = manufac
            };

            var mockProductService = new Mock <IProductService>();
            var mockUserService    = new Mock <IUserService>();

            var mockUserStore = new Mock <IUserStore <Users> >();

            mockUserStore.Setup(u => u.CreateAsync(user, cancel));

            var mockManager = new Mock <UserManager <Users> >(mockUserStore.Object, null, null, null, null, null, null, null, null);

            var Controller = new AdminController(mockProductService.Object, mockManager.Object, mockUserService.Object, null);

            var add = Controller.AddManufacturer(adminModel);

            Assert.IsType <JsonResult>(add);
            Assert.Equal("Manufacturer added!", add.Value);
        }