Exemplo n.º 1
0
        public void GetCompanyWithCountryByIdentifier_EagerLoading()
        {
            var customerIdentifier = 4;
            var ops = new NorthWindDatabaseOperations();

            ops.GetCompanyByCustomerIdentifierEager(customerIdentifier);
        }
Exemplo n.º 2
0
        public void GetCompanyWithCountryByIdentifierSqlClient()
        {
            var customerIdentifier = 4;
            var ops = new NorthWindDatabaseOperations();

            ops.GetCustomersByCustomerIdentifierSqlClientDataProvider(customerIdentifier);
        }
Exemplo n.º 3
0
        public void ObjectsComparerValueMismatchTest()
        {
            var customerIdentifier = 4;
            var ops      = new NorthWindDatabaseOperations();
            var customer = ops.GetCompanyByCustomerIdentifier(customerIdentifier);
            //Assert.IsTrue(customer.Equals(AroundTheHorn));
            var customer1 = AroundTheHorn;

            customer1.FirstName = "Frank";

            var comparer = new ObjectsComparer.Comparer <Company>();

            var positiveCompare = comparer.Compare(customer, customer1, out var differences);

            Assert.IsFalse(positiveCompare);

            var diff = differences.FirstOrDefault();

            Assert.IsTrue(diff != null && diff.DifferenceType == DifferenceTypes.ValueMismatch,
                          "expected ValueMismatch");
            Assert.IsTrue(diff.MemberPath == "FirstName",
                          "expected first name");

            Assert.IsTrue(diff.Value1 == "Thomas",
                          "expected Thomas");

            Assert.IsTrue(diff.Value2 == "Frank",
                          "expected Frank");
        }
Exemplo n.º 4
0
        public void CountWithoutLoadingData()
        {
            var countryIdentifier = 19;
            var ops = new NorthWindDatabaseOperations();
            var countryCountEntityFramework = ops.CountryCountForCustomers(countryIdentifier);
            var countryCountSqlClient       = CountCountry(countryIdentifier);

            Assert.IsTrue(countryCountSqlClient == countryCountEntityFramework,
                          "Expected same count between EF and SqlClient");
        }
Exemplo n.º 5
0
        public void UpdateCustomerContactFirstLastNameTest()
        {
            var company = new Company()
            {
                ContactIdentifier = 4, FirstName = "Karen", LastName = "Payne"
            };
            var ops = new NorthWindDatabaseOperations();

            Assert.IsTrue(ops.UpdateCompanyContactFirstLastName(company));
            company.FirstName = "Thomas";
            company.LastName  = "Hardy";
            Assert.IsTrue(ops.UpdateCompanyContactFirstLastName(company));
        }
Exemplo n.º 6
0
        public void GetCompanyWithCountryByIdentifier()
        {
            var customerIdentifier = 4;
            var ops      = new NorthWindDatabaseOperations();
            var customer = ops.GetCompanyWithCountryByIdentifier(customerIdentifier);

            var customer1 = AroundTheHorn;

            customer1.ContactIdentifier = 4;
            customer1.CountryId         = 19;
            customer1.Country           = "UK";

            var comparer = new ObjectsComparer.Comparer <Company>();

            var isEqual = comparer.Compare(customer1, customer, out var differences);

            Assert.IsTrue(isEqual,
                          "expected customer country test to be the same");
        }
Exemplo n.º 7
0
        public void CompareEntityObjectToLocalInstanceTest()
        {
            var customerIdentifier = 4;
            var ops = new NorthWindDatabaseOperations();

            /*
             * Return specific properties
             */
            var customer = ops.GetCompanyByCustomerIdentifier(customerIdentifier);

            var comparer = new ObjectsComparer.Comparer <Company>();

            var isEqual = comparer.Compare(customer, AroundTheHorn, out var differences);

            Assert.IsTrue(isEqual);

            /*
             * Demonstrate returning all navigation properties
             */
            ops.GetCompanyByCustomerIdentifierTemp(customerIdentifier);
        }
        public void InsertNewCustomerTest()
        {
            var ops = new NorthWindDatabaseOperations();

            /*
             * InsertCustomer is defined in TestBase.
             * newCustomerIdentifier on success of an insert will be the new primary key,
             * otherwise it will be zero.
             *
             * To delete a entity simply create the object with only it's primary key
             */
            var newCustomerIdentifier = ops.InsertCustomer(InsertCustomer());

            Assert.IsTrue(newCustomerIdentifier > 0);

            var deleteCustomer = new Customer()
            {
                CustomerIdentifier = newCustomerIdentifier
            };

            Assert.IsTrue(ops.RemoveCustomer(deleteCustomer));
        }
Exemplo n.º 9
0
        public void RollbackTest()
        {
            var ops = new NorthWindDatabaseOperations();

            ops.RollbackExample();
        }
Exemplo n.º 10
0
        public void InsertNewCustomerTest()
        {
            var ops = new NorthWindDatabaseOperations();

            Assert.IsTrue(ops.InsertCustomer(InsertCustomer()));
        }