Ejemplo n.º 1
0
        public async Task WhenCartIsNotClear_ExpectedOKModel()
        {
            //Arrange
            IEnumerable <IProduct> products = new[] { new Good()
                                                      {
                                                          Price = 1
                                                      }, new Good()
                                                      {
                                                          Price = 2
                                                      } };
            decimal exepectedPrice = 3m;

            var cartServ = new Mock <ICart>();

            cartServ.SetupAllProperties();
            cartServ.Setup((c) => c.All())
            .Returns(products);

            var cart = new preparation.Controllers.CartController(cartServ.Object);
            //Actual
            var res = cart.Index();
            //Assert
            var actionResult = Assert.IsType <ViewResult>(res);
            var model        = Assert.IsAssignableFrom <CartViewModel>(actionResult.ViewData.Model);

            NUnitAssert.AreEqual(products, model.Products);
            NUnitAssert.Null(model.PromoCode);
            NUnitAssert.AreEqual(exepectedPrice, model.TotalPrice);
        }
Ejemplo n.º 2
0
        public static void Null(object value)
        {
#if XUNIT
            FrameworkAssert.Null(value);
#else
            FrameworkAssert.IsNull(value);
#endif
        }
Ejemplo n.º 3
0
        public void ShouldCloseAlert()
        {
            driver.Get("/input.html");
            driver.ExecuteScript("window.setTimeout(function(){alert('test close');}, 100);");
            var alert = driver.SwitchToAlert();

            A.AreEqual("test close", alert.Text);
            alert.Accept();
            A.Null(driver.SwitchToAlert(0, false));
        }
Ejemplo n.º 4
0
        public void ShouldAcceptAlert()
        {
            driver.Get("/input.html");
            driver.ExecuteScript("window.setTimeout(function(){window.res=window.confirm('test dismiss');}, 100);");
            var alert = driver.SwitchToAlert();

            A.AreEqual("test dismiss", alert.Text);
            alert.Dismiss();
            A.False((bool)driver.ExecuteScript("return window.res;"));
            A.Null(driver.SwitchToAlert(0, false));
        }
Ejemplo n.º 5
0
        public void ShouldSendKeysToAlert()
        {
            driver.Get("/input.html");
            driver.ExecuteScript("window.setTimeout(function(){window.res=window.prompt('test prompt','defaultText');}, 100);");
            var alert = driver.SwitchToAlert();

            A.AreEqual("test prompt", alert.Text);
            alert.SendKeys("abcd");
            alert.Accept();
            A.AreEqual("abcd", (string)driver.ExecuteScript("return window.res;"));
            A.Null(driver.SwitchToAlert(0, false));
        }
Ejemplo n.º 6
0
        public async Task WhenCartIsClear_ExpectedNotNullModel()
        {
            //Arrange
            var cartServ = new Mock <ICart>();

            cartServ.SetupAllProperties();
            var cart = new preparation.Controllers.CartController(cartServ.Object);
            //Actual
            var res = cart.Index();
            //Assert
            var actionResult = Assert.IsType <ViewResult>(res);
            var model        = Assert.IsAssignableFrom <CartViewModel>(actionResult.ViewData.Model);

            NUnitAssert.Null(model.Products);
            NUnitAssert.Null(model.PromoCode);
            NUnitAssert.AreEqual(0, model.TotalPrice);
        }
        public void Previously_Instantiated_Objects_Will_Be_Returned_Until_The_Cache_Is_Cleared()
        {
            // Arrange
            var dictionary = new Dictionary <string, object>
            {
                { "CustomerId", 1 },
                { "FirstName", "Bob" },
                { "LastName", "Smith" }
            };

            // Act
            var customer = Slapper.AutoMapper.Map <Customer>(dictionary);

            // Assert
            Assert.AreEqual("Bob", customer.FirstName);

            // Arrange
            var dictionary2 = new Dictionary <string, object> {
                { "CustomerId", 1 }
            };

            // Act
            var customer2 = Slapper.AutoMapper.Map <Customer>(dictionary2);

            // Assert that this will be "Bob" because the identifier of the Customer object was the same,
            // so we recieved back the cached instance of the Customer object.
            Assert.AreEqual("Bob", customer2.FirstName);

            // Arrange
            var dictionary3 = new Dictionary <string, object> {
                { "CustomerId", 1 }
            };

            Slapper.AutoMapper.Cache.ClearInstanceCache();

            // Act
            var customer3 = Slapper.AutoMapper.Map <Customer>(dictionary3);

            // Assert
            Assert.Null(customer3.FirstName);
        }
Ejemplo n.º 8
0
        public void ShouldFindWithNoException()
        {
            var ele = driver.FindElementById("id-missing", 0, false);

            A.Null(ele);
        }