public void Initialize()
        {
            order = new Order();
            order.OrderEntries = null;
            order.SentDate = DateTime.Now;
            order.Id = 10;
            order.User = null;
            userAcc = new UserAccount();
            userAcc.Id = 5;
            orders = new List<Order>();
            orderManagementDaoMock = _factory.CreateMock<IOrderManagementDao>();
            oms.OrderManagementDao = orderManagementDaoMock.MockObject;

            //    NMock.Actions.InvokeAction saveOrder = new NMock.Actions.InvokeAction(new Action(() => orders = new List<Order>(){order}));
              //  orderManagementDaoMock.Expects.Any.MethodWith(x => x.SaveOrUpdate(order)).Will(saveOrder);

            orderInformationDaoMock = _factory.CreateMock<IOrderInformationsDao>();
            ois.OrderInformationDao = orderInformationDaoMock.MockObject;

            orderInformationDaoMock.Expects.Any.MethodWith<Order>(x => x.GetOrderById(order.Id)).WillReturn(order);
            orderInformationDaoMock.Expects.Any.MethodWith<Order>(x => x.GetOrderById(-1)).WillReturn(null);
               // orderInformationDaoMock.Expects.Any.MethodWith(x => x.GetOrdersByUserId(userAcc.Id)).WillReturn(orders.Where(x => x.User.Id == userAcc.Id));
            orderInformationDaoMock.Expects.Any.MethodWith(x => x.GetOrdersByUserId(-1)).WillReturn(orders.Where(x => x.User.Id == userAcc.Id));
            orderInformationDaoMock.Expects.Any.Method(x => x.GetUndeliveredOrders()).WillReturn(orders.Where(x => x.Status != Order.OrderState.DELIVERED));
            orderInformationDaoMock.Expects.Any.MethodWith(x => x.GetUndeliveredByUserId(userAcc.Id)).WillReturn(orders.Where(x => x.Status != Order.OrderState.DELIVERED && x.User.Id == userAcc.Id));
            //orderInformationDaoMock.Expects.Any.MethodWith(x => x.GetDeliveredOrdersByUserId(userAcc.Id)).WillReturn(orders.Where(x => x.Status == Order.OrderState.DELIVERED && x.User.Id == userAcc.Id));
        }
        public void Initialize()
        {
            order = new Order();
            order.OrderEntries = new List<OrderEntry>();
            order.SentDate = DateTime.Now;
            order.User = null;

            orderInformationServiceMock = _factory.CreateMock<IOrderInformationsService>();
            orderManagementServiceMock = _factory.CreateMock<IOrderManagementService>();
            orderManagementDaoMock = _factory.CreateMock<IOrderManagementDao>();
            orderInformationsDaoMock = _factory.CreateMock<IOrderInformationsDao>();

            ois.OrderInformationDao = orderInformationsDaoMock.MockObject;
            oms.OrderManagementDao = orderManagementDaoMock.MockObject;
            oms.OrderInformationDao = orderInformationsDaoMock.MockObject;
            sps.OrderInformationsService = ois;
            sps.OrderManagementService = oms;

            accountAdministrationDao = _factory.CreateMock<IAccountAdministrationDao>();
            userInformationDao = _factory.CreateMock<IUserInformationDao>();
            aas.AccountAdministrationDao = accountAdministrationDao.MockObject;
            aas.UserInformationDao = userInformationDao.MockObject;

            userInformationService = _factory.CreateMock<IUserInformationService>();
            sps.UserInformationService = userInformationService.MockObject;
        }
        public void Initialize()
        {
            suggestionService = new SuggestionService();
            orderInformationServiceMock = _factory.CreateMock<IOrderInformationsService>();
            booksInformationServiceMock = _factory.CreateMock<IBooksInformationService>();

            suggestionService.OrderInformationService = orderInformationServiceMock.MockObject;
            suggestionService.BooksInformationService = booksInformationServiceMock.MockObject;
        }
        public void SetUp()
        {
            factory = new MockFactory();
            camera = factory.CreateMock<Camera>();
            sensor = factory.CreateMock<AbstractTouchSensor>();

            sprite1 = factory.CreateMock<Sprite>();
            sprite2 = factory.CreateMock<Sprite>();
            sprites = new[] { sprite1.MockObject, sprite2.MockObject };
        }
 public void SetupTest()
 {
     dbConnMock = new DynamicMock(typeof (IDatabaseConnection));
     conn = (IDatabaseConnection) dbConnMock.MockInstance;
     statement = new SqlStatement(DatabaseConnection.CurrentConnection);
     statement.Statement.Append(Sql);
     dbConnMock.ExpectAndReturn("LoadDataTable", dt, new object[] {statement, "", ""});
     dbConnMock.ExpectAndReturn("GetConnection", DatabaseConnection.CurrentConnection.GetConnection(),
                                new object[] {});
 }
		protected void SetUp()
		{
			events = new StringBuilder();
			one = new TestComponent("One", events);
			two = new TestComponent("Two", events);
			three = new TestComponent("Three", events);

			mock = new DynamicMock(typeof (IPicoContainer));
			pico = (IPicoContainer) mock.MockInstance;
		}
示例#7
0
		public void SetUp()
		{
			sandboxRoot = TempFileUtil.GetTempPath("MksSandBox");

			mockHistoryParserWrapper = new DynamicMock(typeof (IHistoryParser));
			mockHistoryParser = (IHistoryParser) mockHistoryParserWrapper.MockInstance;

			mksHistoryParserWrapper = new DynamicMock(typeof (MksHistoryParser));
			mksHistoryParser = (MksHistoryParser) mksHistoryParserWrapper.MockInstance;

			mockExecutorWrapper = new DynamicMock(typeof (ProcessExecutor));
			mockProcessExecutor = (ProcessExecutor) mockExecutorWrapper.MockInstance;

			mockIntegrationResult = new DynamicMock(typeof (IIntegrationResult));
			integrationResult = (IIntegrationResult) mockIntegrationResult.MockInstance;
		}
示例#8
0
        public void SetupFixture()
        {
            GlobalRegistry.ApplicationName = appName;
            GlobalRegistry.ApplicationVersion = appVersion;
            GlobalRegistry.DatabaseVersion = dbVersion;
            GlobalRegistry.Settings = settings;
            GlobalRegistry.UIExceptionNotifier = exNotifier;

            itsConnMock = new DynamicMock(typeof(IDatabaseConnection));
            itsConn = (IDatabaseConnection)itsConnMock.MockInstance;
            itsDbMigrator = new DBMigrator(itsConn);
            itsDbMigrator.AddMigration(1, "migration1;");
            itsDbMigrator.AddMigration(2, "migration2;");
            itsDbMigrator.AddMigration(3, "migration3;");

            itsSettingsMock = new DynamicMock(typeof(ISettings));
            _itsSettings = (ISettings)itsSettingsMock.MockInstance;
        }
        public void TestUploadExcelFile()
        {
            //We'll need mocks of context, request and fake file
            var request = new Mock<HttpRequestBase>();
            var context = new Mock<HttpContextBase>();
            var postedfile = new Mock<HttpPostedFileBase>();

            //Someone is going to ask for Request.File and we'll need a mock (fake) of that
            var postedFilesKeyCollection = new Mock<HttpFileCollectionBase>();
            var fakeFileKeys = new List<string>() { "file" };

            //Code being tested for implementation
            HomeController controller = new HomeController();

            ViewResult result = controller.UploadFiles() as ViewResult;
            var uploadResult = result.ViewData.Model as List<ViewDataUploadFilesResult>;
            Assert.AreEqual(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo.doc"), uploadedResult[0].Name);
            Assert.AreEqual(8192, uploadedResult[0].Length);
        }
        public BookShopServiceTest()
        {
            DataPreparation();

            var mockery = new MockFactory();

            _bookRepositoryMock = mockery.CreateMock<IFileSystemStorage<Book>>();
            _bookRepositoryMock.Expects.AtLeastOne
                .Method(m => m.Save(null)).WithAnyArguments();
            _bookRepositoryMock.Expects.AtLeastOne
                .Method(m => m.List()).WithNoArguments().WillReturn(_bookList);

            _customerRepositoryMock = mockery.CreateMock<IFileSystemStorage<Customer>>();
            _customerRepositoryMock.Expects.AtLeastOne
                .Method(m => m.Save(null)).WithAnyArguments();
            _customerRepositoryMock.Expects.AtLeastOne
                .Method(m => m.List()).WithNoArguments().WillReturn(_customerList);

            _bookShopService = new BookShopService(_bookRepositoryMock.MockObject,
                                                    _customerRepositoryMock.MockObject);
        }
		public void SetupTest()
		{
			mockProcessor = new DynamicMock(typeof (ICommandProcessor));
			processor = (ICommandProcessor) mockProcessor.MockInstance;
			selenium = new DefaultSelenium(processor);
		}
示例#12
0
        public void SetUp()
        {
            _preprocessor = _mockFactory.CreateMock<IPreprocessor>(MockStyle.Stub);
            _matcherFactory = _mockFactory.CreateMock<MatcherFactory>(MockStyle.RecursiveStub);

            _searcher = new Searcher(_preprocessor.MockObject, _matcherFactory.MockObject);
        }
示例#13
0
		[SetUp] public void SetUp()
		{
			mock = new Mock("mymock");
		}
示例#14
0
        public void SetUp()
        {
            factory = new MockFactory();
            sensor = factory.CreateMock<AbstractTouchSensor>();
            prompt = factory.CreateMock<TextControl>();
            prompt.Expects.One.Method(_ => _.show());
            prompt.Expects.One.Method(_ => _.hide());
            prompt.Expects.One.Method(_ => _.setText("")).With(Is.TypeOf(typeof(String)));

            sprite = factory.CreateMock<Sprite>();

            messageBox = factory.CreateMock<AbstractMessageBox>();
            messageBox.Expects.One.Method(_ => _.setMessage("")).With(Is.TypeOf(typeof(String)));
            messageBox.Expects.One.Method(_ => _.hide());
            messageBox.Expects.One.Method(_ => _.show());
            gameObject = factory.CreateMock<GameObject>();
            gameObject.Expects.Any.Method(_ => _.GetComponent<Sprite>()).WillReturn(sprite.MockObject);
        }
        public void Initialize()
        {
            TEST_QUANTITY = 5;
            TEST_ADD_QUANTITY = 4;
            TEST_CAT_NAME = "testowa kategoria";
            testCategory = new Category();
            testCategory.Name = TEST_CAT_NAME;
            testBook = new BookType();
            testGetBook = new BookType();
            testBook.Id = 47123;
            testBook.Title = "Książka testowa";
            testBook.Authors = "Autor testowy";
            testBook.Category = testCategory;
            testBook.QuantityMap = new QuantityMap();
            testBook.QuantityMap.Quantity = TEST_QUANTITY;
            testBook.Price = 40;

            categoryList = new List<Category>();
            bookTypeList = new List<BookType>();

             booksInformationDaoMock = _factory.CreateMock<IBooksInformationDao>();
             bis.BooksInformationDao = booksInformationDaoMock.MockObject;
             sms.BooksInformationDao = booksInformationDaoMock.MockObject;

             booksInformationDaoMock.Expects.One.MethodWith<IEnumerable<BookType>>(x => x.GetAllBooks()).WillReturn(bookTypeList);
             booksInformationDaoMock.Expects.One.MethodWith<IList<Category>>(x => x.GetAllCategories()).WillReturn(categoryList);
             booksInformationDaoMock.Expects.One.MethodWith<BookType>(x => x.GetBookTypeById(testBook.Id)).WillReturn(testBook);
             booksInformationDaoMock.Expects.One.MethodWith<BookType>(x => x.GetBookTypeById(testGetBook.Id)).WillReturn(testGetBook);

            storehouseManagementDaoMock = _factory.CreateMock<IStorehouseManagementDao>();
            sms.StorehouseManagementDao = storehouseManagementDaoMock.MockObject;

            NMock.Actions.InvokeAction markSold = new NMock.Actions.InvokeAction(new Action(() => changeQuantity()));
            storehouseManagementDaoMock.Expects.Any.MethodWith(x => x.MarkSold(testBook.Id, testBook.QuantityMap.Quantity)).Will(markSold);
            storehouseManagementDaoMock.Expects.One.MethodWith<bool>(x => x.MarkSold(-1, 5)).WillReturn(false);

            NMock.Actions.InvokeAction saveCategory = new NMock.Actions.InvokeAction(new Action(() => categoryList.Add(testCategory)));
            storehouseManagementDaoMock.Expects.Any.MethodWith(x => x.SaveCategory(testCategory)).Will(saveCategory);
            NMock.Actions.InvokeAction saveBookType = new NMock.Actions.InvokeAction(new Action(() => bookTypeList.Add(testBook)));
            storehouseManagementDaoMock.Expects.Any.MethodWith(x => x.SaveBookType(testBook)).Will(saveBookType);
            NMock.Actions.InvokeAction addCategory = new NMock.Actions.InvokeAction(new Action(() => categoryList.Add(testCategory)));
            storehouseManagementDaoMock.Expects.Any.MethodWith(x => x.AddCategory(TEST_CAT_NAME)).Will(addCategory);
            NMock.Actions.InvokeAction addBookType = new NMock.Actions.InvokeAction(new Action(() => bookTypeList.Add(testBook)));
            storehouseManagementDaoMock.Expects.Any.MethodWith(x => x.AddBookType(testBook.Title, testBook.Authors, testBook.Price, TEST_QUANTITY, testBook.Category)).Will(addBookType);
               // NMock.Actions.InvokeAction addQuantity = new NMock.Actions.InvokeAction(new Action(() =>

            quantityMap = new QuantityMap()
            {
                Quantity = 0
            };

            image = new BookImage()
            {
                URL = ""
            };
            category = new Category()
            {

            };
        }
示例#16
0
 public void SetUp()
 {
     factory = new MockFactory();
     sounds = factory.CreateMock<MockSounds>();
     tracker = new LoopTracker(sounds.MockObject);
 }
示例#17
0
		[Test] public void MockInstanceCanBeUsedAsValueInAnExpectation()
		{
			DynamicMock mockThingy = new DynamicMock(typeof(Thingy));
			Thingy thingy = (Thingy)mockThingy.MockInstance;
			Mock m2 = new Mock("x");

			m2.Expect("y", thingy);
			m2.Invoke("y", new object[] { thingy }, new string[] { "NMock.DynamicMockTest.Thingy" });
			m2.Verify();
		}
 public void TestInitialize()
 {
     AnetConfiguration.CorrelationId = new ThreadLocal<Guid>(() => Guid.NewGuid());
     this.httpActionExecutedContextMock = this.mockFactory.CreateMock<HttpActionExecutedContext>(MockStyle.RecursiveStub);
 }
示例#19
0
 public void SetupTest()
 {
     mockProcessor = new DynamicMock(typeof (ICommandProcessor));
     processor = (ICommandProcessor) mockProcessor.MockInstance;
     mockLauncher = new DynamicMock(typeof(IBrowserLauncher));
     launcher = (IBrowserLauncher) mockLauncher.MockInstance;
     selenium = new DefaultSelenium(processor, launcher);
 }
示例#20
0
 public void SetUp()
 {
     factory = new MockFactory();
     sprite = factory.CreateMock<Sprite>();
 }
 public void SetUp()
 {
     _mockFactory = new MockFactory();
     _mockInvocationHandler = _mockFactory.CreateMock<IInvocationHandler>();
     _module = new TestJavaScriptModule();
 }
示例#22
0
 public void SetUp()
 {
     factory = new MockFactory();
     camera = factory.CreateMock<Camera>();
     inputReturningTouch = inputReturningMockTouch();
 }
 public void Before()
 {
     mockery = new MockFactory();
     auctionEventListener = mockery.CreateMock<IAuctionEventListener>();
     auctionMessageTranslator = new AuctionMessageTranslator(auctionEventListener.MockObject);
 }
        public void Initialize()
        {
            _factory = new MockFactory();
            order = new Order();
            order.OrderEntries = null;
            order.SentDate = DateTime.Now;
            order.User = null;
            getOrder = new Order();
            testBook = new BookType();
            Category testCategory = new Category();
            testBook.Id = 47123;
            testBook.Title = "Książka testowa";
            testBook.Authors = "Autor testowy";
            testBook.Category = testCategory;
            testBook.Price = 40;
            TEST_AMOUNT = 5;

            orderManagementDaoMock = _factory.CreateMock<IOrderManagementDao>();
            oms.OrderManagementDao = orderManagementDaoMock.MockObject;

            orderInformationDaoMock = _factory.CreateMock<IOrderInformationsDao>();
            ois.OrderInformationDao = orderInformationDaoMock.MockObject;
            oms.OrderInformationDao = orderInformationDaoMock.MockObject;

            storehouseManagementDaoMock = _factory.CreateMock<IStorehouseManagementDao>();
            sms.StorehouseManagementDao = storehouseManagementDaoMock.MockObject;

            booksInformationServiceMock = _factory.CreateMock<IBooksInformationService>();
            sms.BooksInformationService = booksInformationServiceMock.MockObject;
            oms.BooksInformationService = booksInformationServiceMock.MockObject;
        }
示例#25
0
 public void Before()
 {
     mockery = new MockFactory();
     sniperListener = mockery.CreateMock<ISniperListener>();
 }
示例#26
0
        public void Initialize()
        {
            authorizationService = new AuthorizationService();
            accountAdministrationService = new AccountAdministrationService();

            helper.UserAccountHelper(userAccount);

            accountAdministrationDaoMock = _factory.CreateMock<IAccountAdministrationDao>();
            authorizationDaoMock = _factory.CreateMock<IAuthorizationDao>();
            authorizationService.AuthorizationDao = authorizationDaoMock.MockObject;
            logInOutEventDaoMock = _factory.CreateMock<ILogEventsDao>();
            authorizationService.LogEventsDao = logInOutEventDaoMock.MockObject;
        }
示例#27
0
 public void SetUp()
 {
     factory = new MockFactory();
     loopTracker = factory.CreateMock<AbstractLoopTracker>();
     sceneFactory = factory.CreateMock<AbstractSceneFactory>();
 }
        public void Initialize()
        {
            var mockBookInformationService = _factory.CreateMock<IBooksInformationService>();
            BookType book = new BookType();
            List<BookType> bookList = new List<BookType>();
            for (int i = 0; i < 10; i++)
            {
                BookType tempBook = new BookType();
                tempBook.Id = i;
                bookList.Add(tempBook);
            }
            nonEmptyList = bookList;
            mockBookInformationService.Expects.Any.Method(_ => _.GetAllBooks()).WillReturn(bookList);
            mockBookInformationService.Expects.Any.Method(_ => _.GetBooksByCategoryId(0)).WithAnyArguments().WillReturn(bookList);
            mockBookInformationService.Expects.Any.Method(_ => _.GetBookTypeById(0)).WithAnyArguments().WillReturn(book);

            suggestionService = new SuggestionService();
            orderInformationServiceMock = _factory.CreateMock<IOrderInformationsService>();
            booksInformationServiceMock = _factory.CreateMock<IBooksInformationService>();

            suggestionService.OrderInformationService = orderInformationServiceMock.MockObject;
            suggestionService.BooksInformationService = booksInformationServiceMock.MockObject;
            //TODO!!
            //AplicationScope.GlobalSuggestionCache = null
        }
示例#29
0
		[Test] [ExpectedException(typeof(VerifyException))] public void ExpectationWillFailIfValueDoesntMatchMockInstance()
		{
			DynamicMock m1 = new DynamicMock(typeof(Thingy));
			Thingy thingy = (Thingy)m1.MockInstance;
			Mock m2 = new Mock("x");

			m2.Expect("y", thingy);
			m2.Invoke("y", new object[] { "something else" }, new string[] { "System.String" });
		}
示例#30
0
 void expectAndReturnAlpha(Mock<Sprite> sprite, float alpha)
 {
     sprite.Expects.AtLeastOne.Method(_ => _.getAlphaAtScreenPosition(null)).WithAnyArguments().WillReturn(alpha);
 }