Example #1
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);
        }
Example #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);
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
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);
        }
Example #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);
        }
Example #7
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);
        }
Example #8
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);
        }
Example #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);
        }
Example #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);
        }
Example #11
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);
        }
Example #12
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);
        }
Example #13
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);
        }
 public void TestFlightEqualsHotel()
 {
     DateTime StartDate = new DateTime(2009, 11, 1);
     DateTime EndDate = new DateTime(2009, 11, 1);
     var target = new Flight(StartDate, EndDate, 700);
     var target2 = new Car(5);
     Assert.False(target.Equals(target2));
 }
Example #15
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));
 }
Example #16
0
        public void TestThatCarCanGetMileageFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();

            mockDatabase.Miles = 500;
            var target = new Car(10);
            target.Database = mockDatabase;
            Assert.AreEqual(target.Mileage, 500);
        }
Example #17
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));
        }
Example #18
0
 public void TestThatCarDoesGetMillageFromDatabase()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     mockDatabase.Miles = 2000;
     var target = new Car(10);
     target.Database = mockDatabase;
     int milesTravled = target.Mileage;
     Assert.AreEqual(2000, milesTravled);
 }
Example #19
0
 public void TestThatCarGetsDatabaseMileage()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     int Miles = 3000;
     mockDatabase.Miles = Miles;
     var target = new Car(10);
     target.Database = mockDatabase;
     int mileCount = target.Mileage;
     Assert.AreEqual(mileCount, Miles);
 }
Example #20
0
 public void TestThatCarDoesGetMileageCountFromDatabase()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     int Miles = 150;
     mockDatabase.Miles = Miles;
     var target = new Car(10);
     target.Database = mockDatabase;
     int Mileage = target.Mileage;
     Assert.AreEqual(Mileage, Miles);
 }
Example #21
0
 public void testCarMilage()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     int miles = 2000;
     mockDatabase.Miles = miles ;
     var target = new Car(1);
     target.Database = mockDatabase;
     int actual = target.Mileage;
     Assert.AreEqual(actual, 2000);
 }
Example #22
0
 public void TestThatCarCanGetMilageFromDatabase()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     int mileage = 1234567;
     mockDatabase.Miles = mileage;
     var target = new Car(10);
     target.Database = mockDatabase;
     int mileCount = target.Mileage;
     Assert.AreEqual(mileCount, mileage);
 }
Example #23
0
        public void TestThatCarDoesGetMileageFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            mockDatabase.Miles = 9001;

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

            Assert.AreEqual(9001, target.Mileage);
        }
Example #24
0
 public void TestThatCarDoesGetMileageFromDatabase()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     int mileage = 100;
     mockDatabase.Miles = mileage;
     var target = new Car(10);
     target.Database = mockDatabase;
     int miles = target.Mileage;
     Assert.AreEqual(miles, mileage);
 }
Example #25
0
 public void TestThatCarGetsMileageFromDatabase()
 {
     int targetMiles = 250000;
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     mockDatabase.Miles = targetMiles;
     var target = new Car(10);
     target.Database = mockDatabase;
     int actualMiles = target.Mileage;
     Assert.AreEqual(actualMiles, targetMiles);
 }
Example #26
0
 public void TestThatCarHasCorrectMileage()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     Int32 Miles = 152000;
     mockDatabase.Miles = Miles;
     var target = new Car(10);
     target.Database = mockDatabase;
     Int32 result = target.Mileage;
     Assert.AreEqual(result, Miles);
 }
Example #27
0
 public void TestMilage()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     Int32 testMiles = 678;
     mockDatabase.Miles = testMiles;
     var target = new Car(67);
     target.Database = mockDatabase;
     Int32 mileCount = target.Mileage;
     Assert.AreEqual(mileCount, testMiles);
 }
Example #28
0
 public void TestThatCarHasCorrectMileage()
 {
     IDatabase mockDatabase = mocks.Stub<IDatabase>();
     Int32 Miles = 15;
     mockDatabase.Miles = Miles;
     var target = new Car(10);
     target.Database = mockDatabase;
     int TestMileage = target.Mileage;
     Assert.AreEqual(Miles, TestMileage);
 }
Example #29
0
        public void TestThatCarDoesGetMileageFromTheDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            int miles = 200;
            mockDatabase.Miles = miles;

            var car = new Car(135);
            car.Database = mockDatabase;
            int result = car.Mileage;
            Assert.AreEqual(result, miles);
        }
Example #30
0
        public void TestThatCarGetsMilesFromDatabase()
        {
            IDatabase mockDatabase = mocks.Stub<IDatabase>();
            Int32 Miles = 10;

            mockDatabase.Miles = Miles;
            var target = new Car(11);
            target.Database = mockDatabase;
            int mileCount = target.Mileage;
            Assert.AreEqual(mileCount, Miles);
        }