Пример #1
0
        void SetUpCurrentVersion(long version, List <long> appliedVersions, bool assertRollbackIsCalled, bool includeBad)
        {
            var providerMock = new DynamicMock(typeof(ITransformationProvider));

            providerMock.SetReturnValue("get_MaxVersion", version);
            providerMock.SetReturnValue("get_AppliedMigrations", appliedVersions);
            providerMock.SetReturnValue("get_Logger", new Logger(false));
            if (assertRollbackIsCalled)
            {
                providerMock.Expect("Rollback");
            }
            else
            {
                providerMock.ExpectNoCall("Rollback");
            }

            _migrator = new Migrator((ITransformationProvider)providerMock.MockInstance, Assembly.GetExecutingAssembly(), false);

            // Enlève toutes les migrations trouvée automatiquement
            _migrator.MigrationsTypes.Clear();
            _upCalled.Clear();
            _downCalled.Clear();

            _migrator.MigrationsTypes.Add(typeof(FirstMigration));
            _migrator.MigrationsTypes.Add(typeof(SecondMigration));
            _migrator.MigrationsTypes.Add(typeof(ThirdMigration));
            _migrator.MigrationsTypes.Add(typeof(FourthMigration));
            _migrator.MigrationsTypes.Add(typeof(SixthMigration));

            if (includeBad)
            {
                _migrator.MigrationsTypes.Add(typeof(BadMigration));
            }
        }
        public void ScheduleActionReturnsValidViewModel()
        {
            this.SetupController();

            // Arrange
            mockServiceTicketRepo.SetReturnValue("FindIncluding", new ServiceTicket {
                ID = 1
            });
            mockEmployeeRepo.SetReturnValue("Find", new Employee {
                ID = 1
            });
            var scheduleItems = new List <ScheduleItem>();

            scheduleItems.Add(new ScheduleItem {
                ID = 1,
            });
            mockScheduleItemRepo.SetReturnValue("AllIncluding", scheduleItems.AsQueryable <ScheduleItem>());

            // Act
            var result = (ViewResult)controller.Schedule(1, 1, 0);

            // Assert
            var model = result.ViewData.Model as ScheduleViewModel;

            Assert.NotNull(model.Employee);
            Assert.NotNull(model.ScheduleItems);
            Assert.NotNull(model.ServiceTicket);
            controller.ViewBag.StartTime = 0;
        }
Пример #3
0
        public static DynamicMock NewMockIErrorRenderer(string name, int hashcode)
        {
            DynamicMock res;

            res = new DynamicMock(name, typeof(IErrorDisplay));
            res.SetReturnValue("Equals", true);
            res.SetReturnValue("GetHashCode", hashcode);

            return(res);
        }
        public void FindAllEconomicActivitiesWhenResult()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            EconomicActivity activityA1 = new EconomicActivity {
                Id = 3, Name = "ServicesA1"
            };
            EconomicActivity activityB2 = new EconomicActivity {
                Id = 4, Name = "ServicesB2"
            };
            EconomicActivity activityA = new EconomicActivity {
                Id = 1, Name = "ServicesA", Parent = null, Childrens = new List <EconomicActivity> {
                    activityA1, activityB2
                }
            };
            EconomicActivity activityB = new EconomicActivity {
                Id = 2, Name = "ServicesB", Parent = null
            };

            List <EconomicActivity> activities = new List <EconomicActivity> {
                activityA, activityB
            };

            _dynamicMock.SetReturnValue("SelectAllEconomicActivities", activities);

            _economicActivityManager  = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            Assert.AreEqual(2, _economicActivityServices.FindAllEconomicActivities().Count);
        }
Пример #5
0
        public void TestSelectMFI()
        {
            MFI mfi = new MFI {
                Name = "MFI", Login = "******", Password = "******"
            };
            MFI returnedMFI = new MFI();

            _mockMFIManagement.SetReturnValue("SelectMFI", mfi);

            MFIServices mfiServices = _SetMockManager(_mockMFIManagement);

            returnedMFI = mfiServices.FindMFI();

            Assert.AreEqual("MFI", returnedMFI.Name);
            Assert.AreEqual("Login", returnedMFI.Login);
            Assert.AreEqual("Password", returnedMFI.Password);
        }
Пример #6
0
        public void TestIfRealPrevisionCurveCorrectlyCalculate()
        {
            int      forecastDays = 10;
            DateTime date         = new DateTime(2006, 1, 1);

            List <KeyValuePair <DateTime, decimal> > cashToDisburseByDay = new List <KeyValuePair <DateTime, decimal> >
            {
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 1), 100),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 2), 200),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 4), 400),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 6), 1233),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 9), 4876)
            };

            List <KeyValuePair <DateTime, decimal> > cashToRepayByDay = new List <KeyValuePair <DateTime, decimal> >
            {
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 1), 100),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 2), 184),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 4), 3944),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 5), 5978),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 7), 6000),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 8), 6001),
                new KeyValuePair <DateTime, decimal>(new DateTime(2006, 1, 10), 6876)
            };

            mockContractManagement.SetReturnValue("CalculateCashToDisburseByDay", cashToDisburseByDay);
            mockContractManagement.SetReturnValue("CalculateCashToRepayByDay", cashToRepayByDay);

            contractManagement = (LoanManager)mockContractManagement.MockInstance;
            this.graphServices = new GraphServices(contractManagement);
            double[] realPrevision = new double[forecastDays];

            realPrevision = this.graphServices.CalculateRealPrevisionCurve(date, forecastDays);

            Assert.AreEqual(10000, realPrevision[0]);
            Assert.AreEqual(9984, realPrevision[1]);
            Assert.AreEqual(9984, realPrevision[2]);
            Assert.AreEqual(13528, realPrevision[3]);
            Assert.AreEqual(19506, realPrevision[4]);
            Assert.AreEqual(18273, realPrevision[5]);
            Assert.AreEqual(24273, realPrevision[6]);
            Assert.AreEqual(30274, realPrevision[7]);
            Assert.AreEqual(25398, realPrevision[8]);
            Assert.AreEqual(32274, realPrevision[9]);
        }
Пример #7
0
        public void TestDeleteUser()
        {
            Assert.Ignore();
            List <User> users = new List <User>();
            User        user  = _AddUser(3, "nicolas", "nicolas", "ADMIN");

            users.Add(new User());

            _mockUserManagement.SetReturnValue("SelectAllUsers", users);
            _mockUserManagement.ExpectAndReturn("Delete", users, user);

            UserServices userServices = _SetMockManager(_mockUserManagement);

            Assert.AreEqual(true, userServices.Delete(user));
            List <User> list = userServices.FindAll(true);

            Assert.AreEqual(1, list.Count);
        }
Пример #8
0
/*
 *              public static object GetModelFromView(IControlView destView)
 *              {
 *                      if (destView is ICategoryEditView)
 *                              return GetCategory();
 *
 *                      throw new NotSupportedException();
 *              }
 */

        public static DynamicMock GetViewMock <T>(params object[] args) where T : IControlView
        {
            var view = new DynamicMock(typeof(T));

            view.SetReturnValue("get_HelperFactory", helperFactory);
            view.SetReturnValue("GetType", typeof(T));

            // TODO: Isso aqui é importante, o ICategoryEditView tem que retornar o valor editado do modelo
            if (typeof(T) == typeof(ICategoryEditView))
            {
                var model = (Category)args[0];
                DataFactory.GetModelEdited <Category, int>(model);

                view.SetReturnValue("get_Model", model);
            }

            return(view);
        }
Пример #9
0
        public void testHandleBar()
        {
            Bar expectedExitBar = new Bar(
                0x000000,
                new DateTime(2011, 2, 1),
                100,
                105,
                99,
                99,
                1
                );

            positionMock.SetReturnValue("get_ExitBar", expectedExitBar);

            Bar bar = new Bar(0x000000, new DateTime(2011, 2, 2), 100, 105, 102, 103, 1);
            ProfitPerPeriod <Month> pnl = AnalyticTools.profitPerMonth((ISecurity)sourceMock.MockInstance);

            Assert.AreEqual(expectedExitBar, pnl.getLastExitBar());
        }
Пример #10
0
        public void TestGetDistrictsWithoutResult()
        {
            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetDistricts", new List <District>());

            LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationServices = new LocationServices(locationsManager);

            Assert.AreEqual(0, locationServices.GetDistricts().Count);
        }
        public void FindAllEconomicActivitiesWhithoutResult()
        {
            _dynamicMock = new DynamicMock(typeof(EconomicActivityManager));
            List <EconomicActivity> activities = new List <EconomicActivity> ();

            _dynamicMock.SetReturnValue("SelectAllEconomicActivities", activities);

            _economicActivityManager  = (EconomicActivityManager)_dynamicMock.MockInstance;
            _economicActivityServices = new EconomicActivityServices(_economicActivityManager);

            Assert.AreEqual(0, _economicActivityServices.FindAllEconomicActivities().Count);
        }
Пример #12
0
        public void Cannot_Register_Null_Display()
        {
            try {
                _emptyToolbar.Register(null); // throws exception
                Assert.Fail();
            }
            catch (Exception e) {
                Assert.True(e.Message.Contains("display"));
            }

            try {
                _rawMock.SetReturnValue("get_PluginItem", null);
                _emptyToolbar.Register((IErrorDisplay)_rawMock.MockInstance); // throws exception
                Assert.Fail();
            }
            catch (Exception e) {
                Assert.True(e.Message.Contains("PluginItem"));
            }

            return;
        }
Пример #13
0
        public void Cannot_Select_UnRegistered_Display()
        {
            DynamicMock unknown = new DynamicMock(typeof(IErrorDisplay));

            _rawMock.SetReturnValue("Equals", false);
            _browserMock.SetReturnValue("Equals", false);

            _filledToolbar.SelectedDisplay =
                (IErrorDisplay)unknown.MockInstance; // throws exception

            return;
        }
Пример #14
0
        public void Setup()
        {
            _errorBrowser = new TestingErrorBrowser();

            _mockStackDisplay = MockHelper.NewMockIErrorRenderer("StackTraceDisplay", 1);
            _mockStackDisplay.SetReturnValue("Text", "Display actual stack trace");

            _stackTraceChanged = false;

            _errorBrowser.StackTraceSourceChanged += new EventHandler(_errorBrowser_StackTraceSourceChanged);

            return;
        }
Пример #15
0
        void SetUpCurrentVersion(int version, bool assertRollbackIsCalled)
        {
            var providerMock = new DynamicMock(typeof(ITransformationProvider));

            providerMock.SetReturnValue("get_CurrentVersion", version);
            providerMock.SetReturnValue("get_Logger", new Logger(false));
            if (assertRollbackIsCalled)
            {
                providerMock.Expect("Rollback");
            }
            else
            {
                providerMock.ExpectNoCall("Rollback");
            }

            _migrationLoader = new MigrationLoader((ITransformationProvider)providerMock.MockInstance, Assembly.GetExecutingAssembly(), true);
            _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.FirstMigration));
            _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.SecondMigration));
            _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.ThirdMigration));
            _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.ForthMigration));
            _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.BadMigration));
            _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.SixthMigration));
            _migrationLoader.MigrationsTypes.Add(typeof(MigratorTest.NonIgnoredMigration));
        }
Пример #16
0
        public void TestDeleteDistrictWithCityIn()
        {
            List <City> cities = _GetCities();

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetCities", cities);
            dynamicMock.Expect("DeleteDistrictById", 2);


            LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            Assert.AreEqual(false, locationService.DeleteDistrict(2));
        }
Пример #17
0
        public void SetUp()
        {
            Panel fakeStackControl = new Panel();
            Panel fakeCodeControl  = new Panel();

            _mockStack = new DynamicMock(typeof(IStackTraceView));
            _mockCode  = new DynamicMock(typeof(ICodeView));

            _mockStack.SetReturnValue("ToControl", fakeStackControl);
            _mockCode.SetReturnValue("ToControl", fakeCodeControl);

            _code = new TestingCode(
                (IStackTraceView)_mockStack.MockInstance,
                (ICodeView)_mockCode.MockInstance);

            return;
        }
Пример #18
0
        public void TestGetCitiesWhithResults()
        {
            List <City> cities = new List <City>
            {
                new City(),
                new City(),
                new City()
            };

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetCities", cities);

            LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationServices = new LocationServices(locationsManager);

            Assert.AreEqual(3, locationServices.GetCities().Count);
        }
Пример #19
0
        public void TestGetDistrictsWhithResults()
        {
            List <District> districts = new List <District>
            {
                new District(),
                new District(),
                new District()
            };

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetDistricts", districts);

            LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationServices = new LocationServices(locationsManager);

            Assert.AreEqual(3, locationServices.GetDistricts().Count);
        }
Пример #20
0
        public void TestDeleteCity()
        {
            List <City> cities = new List <City>();
            City        city   = new City {
                Name = "New York", DistrictId = 12
            };
            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.ExpectAndReturn("AddCity", 3, city);
            dynamicMock.SetReturnValue("GetCities", cities);
            dynamicMock.Expect("DeleteCityById", 2);

            LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            locationService.DeleteCity(2);
            Assert.AreEqual(3, locationService.AddCity(city));
            Assert.AreEqual(0, locationService.GetCities().Count);
        }
Пример #21
0
        public void GetProvincesWhithResults()
        {
            List <Province> provinces = new List <Province>
            {
                new Province(),
                new Province(),
                new Province(),
                new Province()
            };

            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetProvinces", provinces);

            LocationsManager locationsManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationServices = new LocationServices(locationsManager);

            Assert.AreEqual(4, locationServices.GetProvinces().Count);
        }
Пример #22
0
        public void TestUpdateProvince()
        {
            Province        provinceOne = new Province(2, "Pekin");
            List <Province> provinces   = new List <Province> {
                provinceOne
            };


            DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager));

            mockLocationsManager.SetReturnValue("GetProvinces", provinces);
            mockLocationsManager.ExpectAndReturn("UpdateProvince", true, provinceOne);


            LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            Assert.AreEqual("Pekin", locationService.GetProvinces()[0].Name);
            Assert.AreEqual(true, locationService.UpdateProvince(provinceOne));
        }
Пример #23
0
        public void SetUp()
        {
            _emptyToolbar  = new ErrorToolbar();
            _filledToolbar = new ErrorToolbar();

            _rawMock = MockHelper.NewMockIErrorRenderer("raw", 1);
            _rawMock.SetReturnValue("get_PluginItem", new ToolStripButton());
            _raw = (IErrorDisplay)_rawMock.MockInstance;

            _browserMock = MockHelper.NewMockIErrorRenderer("browser", 2);
            _browserMock.SetReturnValue("get_PluginItem", new ToolStripButton());
            _browser = (IErrorDisplay)_browserMock.MockInstance;

            _filledToolbar.Register(_raw);
            _filledToolbar.Register(_browser);

            _rendererChangeNotification             = false;
            _filledToolbar.SelectedRendererChanged += new EventHandler(_filledToolbar_SelectedRendererChanged);

            return;
        }
Пример #24
0
        public void TestUpdateDistrict()
        {
            Province        provinceOne = new Province(2, "Pekin");
            District        district    = new District("Pekin", provinceOne);
            List <District> districts   = new List <District> {
                district
            };


            DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager));

            mockLocationsManager.SetReturnValue("GetDistricts", districts);
            mockLocationsManager.ExpectAndReturn("UpdateDistrict", true, district);


            LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            Assert.AreEqual("Pekin", locationService.GetDistricts()[0].Name);
            Assert.AreEqual(true, locationService.UpdateDistrict(district));
        }
Пример #25
0
        public void TestUpdateCity()
        {
            City city = new City {
                Name = "Pekin", DistrictId = 12
            };
            List <City> cities = new List <City> {
                city
            };

            DynamicMock mockLocationsManager = new DynamicMock(typeof(LocationsManager));

            mockLocationsManager.ExpectAndReturn("AddCity", 3, city);
            mockLocationsManager.SetReturnValue("GetCities", cities);
            mockLocationsManager.ExpectAndReturn("UpdateCity", true, city);


            LocationsManager mocklocationManager = (LocationsManager)mockLocationsManager.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            Assert.AreEqual("Pekin", locationService.GetCities()[0].Name);
            Assert.AreEqual(true, locationService.UpdateCity(city));
        }
Пример #26
0
        public void TestDeleteProvinceWithDistrictIn()
        {
            Province provinceOne = new Province(2, "Pekin");
            Province provinceTwo = new Province(8, "Qhinghua");

            List <District> districts = new List <District>
            {
                new District("Paris", provinceOne),
                new District("Pekin", provinceOne),
                new District("Pau", provinceOne)
            };


            DynamicMock dynamicMock = new DynamicMock(typeof(LocationsManager));

            dynamicMock.SetReturnValue("GetDistricts", districts);
            dynamicMock.Expect("DeleteProvinceById", 8);


            LocationsManager mocklocationManager = (LocationsManager)dynamicMock.MockInstance;
            LocationServices locationService     = new LocationServices(mocklocationManager);

            Assert.AreEqual(false, locationService.DeleteProvince(provinceOne));
        }
Пример #27
0
        public void ErrorDisplay_Plugins_life_cycle_events()
        {
            // test #1: Asks ErrorBrowser to register an instance of IErrorDisplay
            //
            // - check the process calls successively IErrorDisplay's
            //   properties & methods.
            //
            // - when registering an IErrorDisplay for the first time, ErrorBrowser
            //   should select the instance automatically.

            DynamicMock mockTraceDisplay  = MockHelper.NewMockIErrorRenderer("raw", 1);
            DynamicMock mockSourceDisplay = MockHelper.NewMockIErrorRenderer("browser", 2);

            ToolStripButton tracePlugin = new ToolStripButton();

            ToolStripItem[] traceOptions = new ToolStripItem[] { };
            Control         traceContent = new TextBox();

            mockTraceDisplay.SetReturnValue("Text", "Displays the actual stack trace");

            // looks like Mock needs a bit enhancements to handle multiple calls

            mockTraceDisplay.ExpectAndReturn("get_PluginItem", tracePlugin);
            mockTraceDisplay.ExpectAndReturn("get_PluginItem", tracePlugin);
            mockTraceDisplay.ExpectAndReturn("get_PluginItem", tracePlugin);
            mockTraceDisplay.ExpectAndReturn("get_Content", traceContent);
            mockTraceDisplay.Expect("OnStackTraceChanged", new object[] { _errorBrowser.StackTraceSource });

            _errorBrowser.RegisterDisplay((IErrorDisplay)mockTraceDisplay.MockInstance);
            mockTraceDisplay.Verify();

            Assert.That(_errorBrowser.SelectedDisplay, Is.Not.Null);
            Assert.That(_errorBrowser.SelectedDisplay, Is.SameAs(mockTraceDisplay.MockInstance));
            Assert.That(_errorBrowser.LayoutPanel.Content, Is.EqualTo(traceContent));

            // test #2: Asks ErrorBrowser to register another instance of IErrorDisplay
            //
            // - Selection should not change

            ToolStripItem sourcePluginItem = new ToolStripButton();
            Control       sourceContent    = new Button();

            mockSourceDisplay.SetReturnValue("Text", "Displays source code context");
            mockSourceDisplay.ExpectAndReturn("get_PluginItem", sourcePluginItem);
            mockSourceDisplay.ExpectAndReturn("get_PluginItem", sourcePluginItem);

            _errorBrowser.RegisterDisplay((IErrorDisplay)mockSourceDisplay.MockInstance);
            mockSourceDisplay.Verify();

            Assert.That(_errorBrowser.SelectedDisplay, Is.Not.Null);
            Assert.That(_errorBrowser.SelectedDisplay, Is.SameAs(mockTraceDisplay.MockInstance));

            // test #3: changes current selection

            mockTraceDisplay.ExpectAndReturn("get_PluginItem", tracePlugin);
            mockSourceDisplay.ExpectAndReturn("get_PluginItem", sourcePluginItem);
            mockSourceDisplay.ExpectAndReturn("get_Content", sourceContent);

            _errorBrowser.Toolbar.SelectedDisplay = (IErrorDisplay)mockSourceDisplay.MockInstance;

            mockSourceDisplay.Verify();
            mockTraceDisplay.Verify();

            Assert.That(_errorBrowser.Toolbar.SelectedDisplay, Is.SameAs(mockSourceDisplay.MockInstance));
            Assert.That(_errorBrowser.LayoutPanel.Content, Is.EqualTo(sourceContent));

            // test #4: changing ErrorSource update all renderers

            string stack = "à test() C:\\file.cs:ligne 1";

            mockTraceDisplay.Expect("OnStackTraceChanged", new object[] { stack });
            mockSourceDisplay.Expect("OnStackTraceChanged", new object[] { stack });
            _errorBrowser.StackTraceSource = stack;
            Assert.That(_errorBrowser.LayoutPanel.Content, Is.TypeOf(typeof(Button)));
            mockSourceDisplay.Verify();
            mockTraceDisplay.Verify();

            // clears all renderers

            _errorBrowser.ClearAll();
            Assert.That(_errorBrowser.Toolbar.Count, Is.EqualTo(0));

            Assert.That(_errorBrowser.LayoutPanel.Option, Is.Not.Null);
            Assert.That(_errorBrowser.LayoutPanel.Option, Is.TypeOf(typeof(Panel)));

            Assert.That(_errorBrowser.LayoutPanel.Content, Is.Not.Null);
            Assert.That(_errorBrowser.LayoutPanel.Content, Is.TypeOf(typeof(Panel)));

            return;
        }
Пример #28
0
        public void TestSavingIsValid_InitialAmountCorrect()
        {
//            Assert.Ignore();
            SavingBookContract saving = new SavingBookContract(
                ApplicationSettings.GetInstance(""),

                new User {
                Id = 6
            },
                TimeProvider.Today,
                _savingsProduct,
                null)
            {
                InterestRate     = 0.13,
                FlatWithdrawFees = 3,
                FlatTransferFees = 3,
                DepositFees      = 5,
                CloseFees        = 6,
                ManagementFees   = 7,
                AgioFees         = 6
            };
            Client client = new Person {
                Id = 6, LastName = "El Fanidi", Branch = new Branch()
            };

            _savingManagerMock      = new DynamicMock(typeof(SavingManager));
            _savingEventManagerMock = new DynamicMock(typeof(SavingEventManager));

            DynamicMock connectionMock  = new DynamicMock(typeof(SqlConnection));
            DynamicMock transactionMock = new DynamicMock(typeof(SqlTransaction));

            connectionMock.SetReturnValue("BeginTransaction", transactionMock.MockInstance);

            _savingManagerMock.SetReturnValue("GetConnection", connectionMock.MockInstance);

            _savingManagerMock.ExpectAndReturn("GetNumberOfSavings", 1, 6);
            _savingManagerMock.ExpectAndReturn("Add", 1, saving, client, transactionMock.MockInstance);

            _savingServices = new SavingServices(
                (SavingManager)_savingManagerMock.MockInstance,
                (SavingEventManager)_savingEventManagerMock.MockInstance,
                new User {
                Id = 6
            }
                );

            try
            {
                Assert.GreaterOrEqual(_savingServices.SaveContract(saving, client), 0);

                saving = new SavingBookContract(
                    ApplicationSettings.GetInstance(""),

                    new User {
                    Id = 6
                },
                    TimeProvider.Today,
                    _savingsProduct,
                    null)
                {
                    InterestRate     = 0.13,
                    FlatWithdrawFees = 3,
                    FlatTransferFees = 3,
                    DepositFees      = 5,
                    CloseFees        = 6,
                    ManagementFees   = 7,
                    AgioFees         = 6
                };

                _savingManagerMock.ExpectAndReturn("GetNumberOfSavings", 2, 6);
                _savingManagerMock.ExpectAndReturn("Add", 2, saving, client, transactionMock.MockInstance);

                Assert.GreaterOrEqual(_savingServices.SaveContract(saving, client), 0);
            }
            catch (OpenCbsSavingException exception)
            {
                Assert.Fail(exception.Code.ToString());
            }
        }