Esempio n. 1
0
        //Arrange
        public void LoginProperlyReturnsACustomerType()
        {
            var options = new DbContextOptionsBuilder <SGDB2Context>()
                          .UseInMemoryDatabase(databaseName: "SGDB2")
                          .Options;

            using (var context = new SGDB2Context(options))
            {
                using (var sw = new StringWriter())
                {
                    using (var sr = new StringReader("abe\nyup"))
                    {
                        context.Add(new Customers
                        {
                            UserName = "******",
                            Pword    = "yup"
                        });

                        context.SaveChanges();

                        //Act
                        Console.SetOut(sw);
                        Console.SetIn(sr);
                        Customers    customer     = new Customers();
                        StoreMethods storeMethods = new StoreMethods();
                        customer = storeMethods.Login(context);


                        //Assert
                        Assert.IsType <Customers>(customer);
                    }
                }
            }
        }//End Test 1