Exemplo n.º 1
0
        public void TestThatCarDoesGetCarLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            int car1 = 10;
            String car1Location = "Hawaii";

            int car2 = 50;
            String car2Location = "Indiana";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(car1);
                LastCall.Return(car1Location);

                mockDatabase.getCarLocation(car2);
                LastCall.Return(car2Location);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(10);
            Assert.AreEqual(result, car1Location);

            result = target.getCarLocation(50);
            Assert.AreEqual(result, car2Location);
        }
Exemplo n.º 2
0
        public void TestThatCarDoesGetLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String carLocation = "My Garage";
            String anotherCarLocation = "Stelvio Pass";

            using (mocks.Record())
            {
                // The mock will return "My Garage" when the call is made with 15
                mockDatabase.getCarLocation(15);
                LastCall.Return(carLocation);

                // The mock will return "Stelvio Pass" when the call is made with 23
                mockDatabase.getCarLocation(23);
                LastCall.Return(anotherCarLocation);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(15);
            Assert.AreEqual(result, carLocation);

            result = target.getCarLocation(23);
            Assert.AreEqual(result, anotherCarLocation);
        }
Exemplo n.º 3
0
        public void TestThatCarDoesGetCarLocationFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String location1 = "Lot A";
            String location2 = "Lot C";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(5);
                LastCall.Return(location1);

                mockDatabase.getCarLocation(10);
                LastCall.Return(location2);
            }

            var target = new Car(5);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(5);
            Assert.AreEqual(result, location1);

            result = target.getCarLocation(10);
            Assert.AreEqual(result, location2);
        }
Exemplo n.º 4
0
        public void TestGetCorrectCarLocationFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String location1 = "Terre Haute, Indiana";
            String location2 = "Morristown, Indiana";

            using (mocks.Record())
            {
                // The mock will return "Terre Haute, Indiana" when the call is made with 1
                mockDatabase.getCarLocation(1);
                LastCall.Return(location1);
                // The mock will return "Morristown, Indiana" when the call is made with 2
                mockDatabase.getCarLocation(2);
                LastCall.Return(location2);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(1);
            Assert.AreEqual(result, location1);
            result = target.getCarLocation(2);
            Assert.AreEqual(result, location2);
        }
Exemplo n.º 5
0
        public void TestThatCarGetsLocationFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String firstLocation = "Terre Haute";
            String otherLocation = "Spaaaaace!";

            using(mocks.Record())
            {
                mockDatabase.getCarLocation(15);
                LastCall.Return(firstLocation);

                mockDatabase.getCarLocation(311);
                LastCall.Return(otherLocation);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(311);
            Assert.AreEqual(result, otherLocation);

            result = target.getCarLocation(15);
            Assert.AreEqual(result, firstLocation);
        }
Exemplo n.º 6
0
        public void TestThatCarCanGetCarLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String carLocation1337 = "Home";
            String carLocation1024 = "Mars";

            using(mocks.Record())
            {
                // The mock will return "Mars" when the call is made with 1024
                mockDatabase.getCarLocation(1024);
                LastCall.Return(carLocation1024);

                // The mock will return "Home" when the call is made with 1337
                mockDatabase.getCarLocation(1337);
                LastCall.Return(carLocation1337);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(1337);
            Assert.AreEqual(result, carLocation1337);

            result = target.getCarLocation(1024);
            Assert.AreEqual(result, carLocation1024);
        }
Exemplo n.º 7
0
        public void TestThatCarDoesGetLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String carLocation = "On a whale";
            String anotherCarLocation = "On a raptor ranch";

            using (mocks.Record())
            {
                // The mock will return "On a whale" when the call is made with 24
                mockDatabase.getCarLocation(24);
                LastCall.Return(carLocation);
                // The mock will return "Raptor Wrangler" when the call is made with 1025
                mockDatabase.getCarLocation(1025);
                LastCall.Return(anotherCarLocation);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(1025);
            Assert.AreEqual(result, anotherCarLocation);

            result = target.getCarLocation(24);
            Assert.AreEqual(result, carLocation);
        }
Exemplo n.º 8
0
        public void TestThatCarDoesGetCarLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            int carNumber1 = 34;
            int carNumber2 = 55;
            String carLocation1 = "1397B";
            String carLocation2 = "1678D";
            int daysToRent = 10;

            using(mocks.Record())
            {
              mockDatabase.getCarLocation(carNumber1);
              LastCall.Return(carLocation1);

              mockDatabase.getCarLocation(carNumber2);
              LastCall.Return(carLocation2);
            }

            var target = new Car(daysToRent);
            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(carNumber2);
            Assert.AreEqual(carLocation2, result);

            result = target.getCarLocation(carNumber1);
            Assert.AreEqual(carLocation1,result);
        }
Exemplo n.º 9
0
        public void TestCarLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String car1 = "Here";
            String car2 = "There";
            using (mocks.Record())
            {
                mockDatabase.getCarLocation(5);
                LastCall.Return(car1);

                mockDatabase.getCarLocation(8);
                LastCall.Return(car2);
            }

            var target = new Car(5);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(5);
            Assert.AreEqual(result, car1);

            result = target.getCarLocation(8);
            Assert.AreEqual(result, car2);
        }
Exemplo n.º 10
0
        public void TestThatCarDoesGetLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String carLocation = "Parking lot A53, row 6, next to the rabid squirrels' nest";
            String anotherCarLocation = "Forever lost";
            using (mocks.Record())
            {
                // The mock will return "Whale Rider" when the call is made with 24
                mockDatabase.getCarLocation(24);
                LastCall.Return(carLocation);
                // The mock will return "Raptor Wrangler" when the call is made with 1025
                mockDatabase.getCarLocation(1025);
                LastCall.Return(anotherCarLocation);
            }
            var target = new Car(10);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(1025);
            Assert.AreEqual(result, anotherCarLocation);

            result = target.getCarLocation(24);
            Assert.AreEqual(result, carLocation);
        }
Exemplo n.º 11
0
        public void TestThatCarDoesGetCarLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String carLocation = "there";
            String anotherCarLocation = "everywhere";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(17);
                LastCall.Return(carLocation);
                mockDatabase.getCarLocation(5);
                LastCall.Return(anotherCarLocation);
            }
            var target = new Car(10);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(5);
            Assert.AreEqual(result, anotherCarLocation);

            result = target.getCarLocation(17);
            Assert.AreEqual(result, carLocation);
        }
Exemplo n.º 12
0
        public void TestThatCarDoesGetMileageFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String ZeroMileage = "Zero mileage, you're going nowhere";
            String NegativeMileage = "Neagive mileage, you're going backwards";
            String PositiveMileage = "Positive Mileage, you're doing it right";

            using (mocks.Record())
            {

                mockDatabase.getCarLocation(0);
                LastCall.Return(ZeroMileage);

                mockDatabase.getCarLocation(-45);
                LastCall.Return(NegativeMileage);

                mockDatabase.getCarLocation(80);
                LastCall.Return(PositiveMileage);
            }

            var target = new Car(10);

            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(0);
            Assert.AreEqual(result, ZeroMileage);
            result = target.getCarLocation(-45);
            Assert.AreEqual(result, NegativeMileage);
            result = target.getCarLocation(80);
            Assert.AreEqual(result, PositiveMileage);
        }
Exemplo n.º 13
0
        public void TestThatCarDoesGetLocationFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String car = "Beetle";
            String truck = "Wat";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(1);
                LastCall.Return(car);

                mockDatabase.getCarLocation(2);
                LastCall.Return(truck);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result = target.getCarLocation(1);
            Assert.AreEqual(result, car);

            result = target.getCarLocation(2);
            Assert.AreEqual(result, truck);
        }
Exemplo n.º 14
0
 public void TestgetCarLocation()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     var target = new Car(3);
     target.Database = mockDatabase;
     String carLocation = target.getCarLocation(15);
     Assert.AreEqual(carLocation, mockDatabase.getCarLocation(15));
 }
Exemplo n.º 15
0
        public void TestThatCarCanGetLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            var target = new Car(10);
            target.Database = mockDatabase;
            String carLoc = target.getCarLocation(1);
            Assert.AreEqual(carLoc, mockDatabase.getCarLocation(1));
        }
Exemplo n.º 16
0
 public void TestGetCarLocationFromDatabase()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     String carlocation = "Chicago";
     String anothercarlocation = "Terre Haute";
     using (mocks.Record())
     {
         mockDatabase.getCarLocation(22);
         LastCall.Return(carlocation);
         mockDatabase.getCarLocation(24);
         LastCall.Return(anothercarlocation);
     }
     var target = new Car(5);
     target.Database = mockDatabase;
     String result;
     result = target.getCarLocation(22);
     Assert.AreEqual(result, carlocation);
     result = target.getCarLocation(24);
     Assert.AreEqual(result, anothercarlocation);
 }
Exemplo n.º 17
0
 public void TestThatCarDoesGetLocationFromTheDatabase()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     String carLocation = "Whale Rider";
     String carLocation2 = "Raptor Wrangler";
     using(mocks.Record())
     {
         mockDatabase.getCarLocation(24);
         LastCall.Return(carLocation);
         mockDatabase.getCarLocation(1025);
         LastCall.Return(carLocation2);
     }
     var target = new Car(10);
     target.Database = mockDatabase;
     String result;
     result = target.getCarLocation(1025);
     Assert.AreEqual(result, carLocation2);
     result = target.getCarLocation(24);
     Assert.AreEqual(result, carLocation);
 }
Exemplo n.º 18
0
        public void TestGetCarLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String testA = "Terre-Haute";
            String testB = "Tucson, Arizona";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(10);
                LastCall.Return("Terre-Haute");

                mockDatabase.getCarLocation(1337);
                LastCall.Return("Tucson, Arizona");
            }

            var target = new Car(10);

            target.Database = mockDatabase;
            Assert.AreEqual(testA, target.getCarLocation(10));
            Assert.AreEqual(testB, target.getCarLocation(1337));
        }
Exemplo n.º 19
0
 public void TestGetCarLocation()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     String Sriram = "Sriram's House";
     String Rose = "Rose";
     using (mocks.Record())
     {
         // The mock will return "Whale Rider" when the call is made with 24
         mockDatabase.getCarLocation(1);
         LastCall.Return(Sriram);
         mockDatabase.getCarLocation(2);
         LastCall.Return(Rose);
     }
     var target = new Car(10);
     target.Database = mockDatabase;
     String result;
     result = target.getCarLocation(1);
     Assert.AreEqual(result, Sriram);
     result = target.getCarLocation(2);
     Assert.AreEqual(result, Rose);
 }
Exemplo n.º 20
0
 public void TestThatCarGetsCarLocation()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     List<Int32> cars = new List<int>();
     for (var i = 1; i < 100; i++)
     {
         cars.Add(i);
         var target = new Car(i);
         target.Database = mockDatabase;
         String carLocation = target.getCarLocation(i);
         Assert.AreEqual(mockDatabase.getCarLocation(i), carLocation);
     }
 }
Exemplo n.º 21
0
        public void TestCarLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String carLoc1 = "Neverland";
            String carLoc2 = "Dark Side of the Moon";
            using (mocks.Record())
            {
                mockDatabase.getCarLocation(1);
                LastCall.Return(carLoc1);
                mockDatabase.getCarLocation(2);
                LastCall.Return(carLoc2);
            }
            var target = new Car(1);

            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(1);
            Assert.AreEqual(result, carLoc1);
            result = target.getCarLocation(2);
            Assert.AreEqual(result, carLoc2);
        }
Exemplo n.º 22
0
        public void TestThatCarDoesGetCarLocationFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            string location1 = "The Moon";
            string location2 = "Mars";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(5);
                LastCall.Return(location1);

                mockDatabase.getCarLocation(7);
                LastCall.Return(location2);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            string rval = target.getCarLocation(7);
            Assert.AreEqual(rval, location2);

            rval = target.getCarLocation(5);
            Assert.AreEqual(rval, location1);
        }
Exemplo n.º 23
0
        public void TestThatCarGetsLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String location1 = "here";
            String location2 = "OVER NINE THOUSAND!";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(2);
                LastCall.Return(location1);
                mockDatabase.getCarLocation(9001);
                LastCall.Return(location2);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(2);
            Assert.AreEqual(result, location1);
            result = target.getCarLocation(9001);
            Assert.AreEqual(result, location2);
        }
Exemplo n.º 24
0
        public void TestThatCarDoesGetCarLocationFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            int carnum1 = 222;
            int carnum2 = 105;
            String carloc1 = "Seattle";
            String carloc2 = "Madison";
            using(mocks.Record())
            {
                mockDatabase.getCarLocation(carnum1);
                LastCall.Return(carloc1);
                mockDatabase.getCarLocation(carnum2);
                LastCall.Return(carloc2);
            }

            String result;
            Car car = new Car(3);
            car.Database = mockDatabase;
            result = car.getCarLocation(carnum1);
            Assert.AreEqual(result, carloc1);

            result = car.getCarLocation(carnum2);
            Assert.AreEqual(result, carloc2);
        }
Exemplo n.º 25
0
        public void TestCarLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String location= "Terre Haute, IN";
            String anotherLocation = "Lexington, KY";

            using (mocks.Record())
            {
                // The mock will return "Whale Rider" when the call is made with 24
                mockDatabase.getCarLocation(50);
                LastCall.Return(location);
                // The mock will return "Raptor Wrangler" when the call is made with 1025
                mockDatabase.getCarLocation(1025);
                LastCall.Return(anotherLocation);

            }
            var target = new Car(11);
            target.Database = mockDatabase;
            String result;
            result = target.getCarLocation(50);
            Assert.AreEqual(result, location);
            result = target.getCarLocation(1025);
            Assert.AreEqual(result, anotherLocation);
        }
Exemplo n.º 26
0
        public void TestThatCarGetsLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            using (mocks.Record())
            {

                mockDatabase.getCarLocation(10);
                LastCall.Return("Sheboygan");
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result = target.getCarLocation(10);

            Assert.AreEqual("Sheboygan", result);
        }
Exemplo n.º 27
0
        public void TestGetCarLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            String carLocation = "Tokyo";
            using (mocks.Record())
            {
                // The mock will return Tokyo when the call is made with 1
                mockDatabase.getCarLocation(1);
                LastCall.Return(carLocation);
            }
            var target = new Car(10);
            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(1);
            Assert.AreEqual(result, carLocation);
        }
Exemplo n.º 28
0
        public void TestThatCarGetsCarLocation()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            int carNumber = 10;
            String carLocation = "Home";

            using (mocks.Record())
            {
                mockDatabase.getCarLocation(carNumber);
                LastCall.Return(carLocation);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;
            result = target.getCarLocation(carNumber);
            Assert.AreEqual(result, carLocation);
        }
Exemplo n.º 29
0
        public void TestThatCarDoesGetLocationFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            String car24Location = "123 Maple";
            String car1025Location = "The Moon";
            using (mocks.Record())
            {
                mockDatabase.getCarLocation(24);
                LastCall.Return(car24Location);

                mockDatabase.getCarLocation(1025);
                LastCall.Return(car1025Location);
            }

            var target = new Car(10);
            target.Database = mockDatabase;

            String result;

            result = target.getCarLocation(1025);
            Assert.AreEqual(car1025Location, result);
        }
Exemplo n.º 30
0
        public void TestThatCarLocationIsInDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            using (mocks.Record())
            {
                mockDatabase.getCarLocation(10);
                LastCall.Return("San Fran");
                mockDatabase.getCarLocation(9001);
                LastCall.Return("There's no way that can be right.");
            }
            var target = new Car(500);
            target.Database = mockDatabase;
            String result;
            result = target.getCarLocation(10);
            Assert.AreEqual("San Fran", result);

            result = target.getCarLocation(9001);
            Assert.AreEqual("There's no way that can be right.", result);
        }