Exemple #1
0
        //Arrange
        public void SearchCustomerReturnsCustomerName()
        {
            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("a"))
                    {
                        Customers custy = new Customers {
                            FirstName = "al", LastName = "ali"
                        };
                        context.Add(custy);
                        context.SaveChanges();

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


                        //Assert
                        Assert.Contains("al\r\n", sw.ToString());
                    }
                }
            }
        }//Test 9