예제 #1
0
        public void TestCustomer(string fname, string lname, string username, string password)
        {
            // ARRANGE - create the data to insert into the Db
            //create the new Person seed
            AuthModel authModel = new AuthModel()
            {
                FirstName = fname,
                LastName  = lname,
                Username  = username,
                Password  = password
            };
            Customer outCustomer = null;
            bool     success     = false;

            using (var context1 = new DbContextClass(testOptions))
            {
                context1.Database.EnsureDeleted(); //do this ONCE at hte beginning of each test
                context1.Database.EnsureCreated(); // this creates the new-for-this-test database

                //create the MemeSaverRepo instance
                ToyRepository msr = new ToyRepository(context1);

                success = msr.RegisterTest(authModel, out outCustomer);
            }

            Assert.True(success);
            Assert.Equal(outCustomer.FirstName, authModel.FirstName);
            Assert.Equal(outCustomer.LastName, authModel.LastName);
            Assert.Equal(outCustomer.CustomerUName, authModel.Username);

            // ACT - call the method that inserts into the Db
            Customer outCustomer2 = new Customer();

            using (var context2 = new DbContextClass(testOptions))
            {
                context2.Database.EnsureCreated();
                ToyRepository msr = new ToyRepository(context2);
                success = msr.LoginTest(authModel, out outCustomer2);
                // success = context2.Persons.Where(x => x.PasswordHash == testPerson.PasswordHash).FirstOrDefault();
            }

            // ASSERT - verify the the data state is as expected
            Assert.Equal(outCustomer2.FirstName, authModel.FirstName);
            Assert.Equal(outCustomer2.LastName, authModel.LastName);
            Assert.Equal(outCustomer2.CustomerUName, authModel.Username);
            Assert.True(success);
        }
예제 #2
0
 public SellableLogic(ToyRepository toyRepository)
 {
     this._toyRepository = toyRepository;
 }
예제 #3
0
 public OrderLogic(ToyRepository _toyRepository, Authenticator _authenticator)
 {
     this._toyRepository = _toyRepository;
     this._authenticator = _authenticator;
 }