public void SetUp()
        {
            _factory = new MockFactory();

            List<CommonEvent> mockResult;

            var mock1 = _factory.CreateMock<BaseEventCollector>();
            mockResult = new List<CommonEvent>();
            mockResult.AddRange(new[]
                      {
                          new CommonEvent(0, "100", "Mock1Event1", new DateTime(2013,10,15), null, "", "", "", "", "", ""),
                          new CommonEvent(0, "100", "Mock1Event2", new DateTime(2013,10,1), null, "", "", "", "", "", ""),
                      });
            mock1.Expects.One.MethodWith(x => x.GetEvents(201307, "松山")).WillReturn(mockResult);

            var mock2 = _factory.CreateMock<BaseEventCollector>();
            mockResult = new List<CommonEvent>();
            mockResult.AddRange(new[]
                      {
                          new CommonEvent(0, "100", "Mock2Event1", new DateTime(2013,10,8), null, "", "", "", "", "", ""),
                          new CommonEvent(0, "100", "Mock2Event2", new DateTime(2013,10,30), null, "", "", "", "", "", ""),
                          new CommonEvent(0, "100", "Mock2Event3", new DateTime(2013,10,25), null, "", "", "", "", "", ""),
                      });
            mock2.Expects.One.MethodWith(x => x.GetEvents(201307, "松山")).WillReturn(mockResult);

            sut = new AllEventCollector(new[] { mock1.MockObject, mock2.MockObject });
        }
        public void TestPersist()
        {
            MockFactory factory = new MockFactory();

            //Create mocks
            Mock<IUserGateway> mockGateway = factory.CreateMock<IUserGateway>();
            Mock<IUserValidator> mockValidator = factory.CreateMock<IUserValidator>();

            //Create user
            User user = new User();

            //Expectations
            using(factory.Ordered)
            {
                mockValidator.Expects.One.MethodWith(m => m.Validate(user)).WillReturn(true);
                mockGateway.Expects.One.MethodWith(m => m.Persist(user)).WillReturn(true);
            }

            //Assign gateway
            user.Gateway = mockGateway.MockObject;

            //Test method
            Assert.AreEqual(true, user.Persist(mockValidator.MockObject));

            factory.VerifyAllExpectationsHaveBeenMet();
        }
            public Mocks(MockFactory mockFactory)
            {
                ClassProvider = mockFactory.CreateMock <INullableValueProvider <IClassDeclaration> >();
                ClassMemberDeclarationFactory = mockFactory.CreateMock <IFactory <IClassDeclaration> >();

                Sut = new AddMemberDeclarationToClass(
                    ClassProvider.MockObject, ClassMemberDeclarationFactory.MockObject);
            }
Example #4
0
        public void Initialize()
        {
            suggestionService           = new SuggestionService();
            orderInformationServiceMock = _factory.CreateMock <IOrderInformationsService>();
            booksInformationServiceMock = _factory.CreateMock <IBooksInformationService>();

            suggestionService.OrderInformationService = orderInformationServiceMock.MockObject;
            suggestionService.BooksInformationService = booksInformationServiceMock.MockObject;
        }
Example #5
0
        public void MockToStringOnClass()
        {
            Mock <TestClass1> mock = mockFactory.CreateMock <TestClass1>();

            mock.Expects.One.Method(_ => _.ToString()).Will(Return.Value("whatYouWant"));

            string s = mock.MockObject.ToString();

            Assert.AreEqual("whatYouWant", s);
        }
        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 };
        }
Example #7
0
        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 };
        }
Example #8
0
        public void MockStyleForStub()
        {
            StubMockStyleDictionary testee = new StubMockStyleDictionary();
            Mock <IMockObject>      mock   = mockFactory.CreateMock <IMockObject>();

            testee[mock.MockObject] = MockStyle.Stub;

            Assert.AreEqual(MockStyle.Stub, testee[mock.MockObject]);
            Assert.AreEqual(MockStyle.Stub, testee[mock.MockObject, typeof(IHelloWorld)]);
        }
Example #9
0
        protected void Initalize()
        {
            mocks = new List <Mock <IParentInterface> >();
            mocks.Add(Factory.CreateMock <IParentInterface>("parentInterfaceMock"));
            mocks.Add(Factory.CreateMock <IChildInterface>("childInterfaceMock").As <IParentInterface>());
            mocks.Add(Factory.CreateMock <IGenericInterface <System.Version> >("genericInterfaceOfVersionMock").As <IParentInterface>());
            mocks.Add(Factory.CreateMock <ParentClass>("parentClassMock").As <IParentInterface>());
            mocks.Add(Factory.CreateMock <ChildClass>(DefinedAs.Named("classMock").WithArgs("Phil")).As <IParentInterface>());
            mocks.Add(Factory.CreateMock <GenericClass <System.Version> >("genericClassOfVersionMock").As <IParentInterface>());
            mocks.Add(Factory.CreateMock <AbstractParentClass>("abstractParentClassMock").As <IParentInterface>());
            //mocks.Add(Factory.CreateMock<SealedChildClass>("sealedChildClassMock").As<IParentInterface>());
#if !SILVERLIGHT
            mocks.Add(Factory.CreateMock <ExplicitImplementationParentClass>("explicitImplementationParentClassMock").As <IParentInterface>());
            mocks.Add(Factory.CreateMock <InternalParentClass>("internalParentClassMock").As <IParentInterface>());
#endif

            instances = new List <IParentInterface>();
            instances.Add(Factory.CreateInstance <IParentInterface>("parentInterfaceInstance"));
            instances.Add(Factory.CreateInstance <IChildInterface>("childInterfaceInstance"));
            instances.Add(Factory.CreateInstance <IGenericInterface <System.Version> >("genericInterfaceOfVersionInstance"));
            instances.Add(Factory.CreateInstance <ParentClass>("parentClassInstance"));
            instances.Add(Factory.CreateInstance <ChildClass>(DefinedAs.Named("classInstance").WithArgs("Phil")));
            instances.Add(Factory.CreateInstance <GenericClass <System.Version> >("genericClassOfVersionInstance"));
            instances.Add(Factory.CreateInstance <AbstractParentClass>("abstractParentClassInstance"));
#if !SILVERLIGHT
            instances.Add(Factory.CreateInstance <ExplicitImplementationParentClass>("explicitImplementationParentClassInstance"));
            instances.Add(Factory.CreateInstance <InternalParentClass>("internalParentClassInstance"));
#endif
        }
Example #10
0
        public void startShouldInitializeChannelsWithConfigurationSettings()
        {
            var iConfigurationSettingsMock = factory.CreateMock <IConfigurationSettings>();
            var iMessagingFacilityMock     = factory.CreateMock <IMessagingFacility <Invoice, ProcessingResult> >();
            var iExceptionHandlerMock      = factory.CreateMock <IExceptionHandler>();
            var iInvoiceProcessorMock      = factory.CreateMock <IInvoiceProcessor>();

            var worker = new WorkerImpl
                         (
                iConfigurationSettingsMock.MockObject,
                iMessagingFacilityMock.MockObject,
                iExceptionHandlerMock.MockObject,
                iInvoiceProcessorMock.MockObject
                         );

            iConfigurationSettingsMock.Expects.One.
            MethodWith(_ => _.GetSettingsByKey("inputQueue")).
            Will(Return.Value("foo"));
            iConfigurationSettingsMock.Expects.One.
            MethodWith(_ => _.GetSettingsByKey("outputQueue")).
            Will(Return.Value("bar"));

            iMessagingFacilityMock.Expects.One.
            MethodWith(_ => _.InitializeInputChannel("foo"));
            iMessagingFacilityMock.Expects.One.
            MethodWith(_ => _.InitializeOutputChannel("bar"));

            worker.Start();
        }
Example #11
0
        public void SetUp()
        {
            _preprocessor   = _mockFactory.CreateMock <IPreprocessor>(MockStyle.Stub);
            _matcherFactory = _mockFactory.CreateMock <MatcherFactory>(MockStyle.RecursiveStub);

            _searcher = new Searcher(_preprocessor.MockObject, _matcherFactory.MockObject);
        }
Example #12
0
        public void SaveContactTest()
        {
            //Assert.Ignore("Ignore for now"); //TODO: remove later in the exercise
            //Create a MockFactory
            MockFactory factory = new MockFactory();

            //Create an instance of an IAddressStandardizationService Mock and IContactManagementDataSource Mock
            Mock <IStandardizationService>      addressService = factory.CreateMock <IStandardizationService>();
            Mock <IContactManagementDataSource> dataSource     = factory.CreateMock <IContactManagementDataSource>();

            //Create the ContactManagementBusinessLogic
            ContactManagementBusinessLogic businessLogic = new ContactManagementBusinessLogic(addressService.MockObject, dataSource.MockObject);

            //Contact to be passed to the businesslogic
            Contact contactIN = new Contact(123);

            //SaveContactResult to be returned by the businessLogic
            SaveContactResult result = new SaveContactResult();

            result.ContactId       = 123;
            result.RecordsAffected = 1;

            //Address to be passed in to the addressService
            Address addressIN = new Address(0, "123 S. 201st St.", string.Empty, "Omaha", "NE", "68154", "USA", AddressType.Home);

            contactIN.Addresses.Add(addressIN);

            //Address to be returned by the addressService
            Address addressOUT = new Address(0, "123 S 201 ST", string.Empty, "Omaha", "NE", "68154", "USA", AddressType.Home);

            int rowsAffected = 2;

            //Add the expectations
            dataSource.Expects.One
            .Method(d => d.SaveContact(null))                     //this method param is needed for the compiler
            .With(contactIN)
            .Will(Return.Value(result));

            addressService.Expects.One
            .Method(a => a.StandardizeAddress(null))                     //this method param is needed for the compiler
            .With(addressIN)
            .Will(Return.Value(addressOUT));

            dataSource.Expects.One
            .Method(d => d.SaveAddress(0, null))
            .With(contactIN.Id, addressOUT)
            .Will(Return.Value(1));

            //Call the method
            int i = businessLogic.SaveContact(contactIN);

            //Add the unit test assertion
            Assert.AreEqual(rowsAffected, i);
        }
Example #13
0
        public DiagnosticoTratamientoServiceTest()
        {
            var mock = new MockFactory();

            _diagnosticoRepositoryMock            = mock.CreateMock <IDiagnosticoRepository>();
            _tratamientoRepositoryMock            = mock.CreateMock <ITratamientoRepository>();
            _materialSoportePlantarRepositoryMock = mock.CreateMock <IMaterialSoportePlantarRepository>();

            _diagnosticoTratamientoService = new DiagnosticoTratamientoService(_diagnosticoRepositoryMock.MockObject,
                                                                               _tratamientoRepositoryMock.MockObject, _materialSoportePlantarRepositoryMock.MockObject);
        }
Example #14
0
        public void GetRecordCount()
        {
            PhoneOrderService           phoneOrderService        = new PhoneOrderService();
            Mock <PhoneOrderRepository> mockPhoneOrderRepository = mockFactory.CreateMock <PhoneOrderRepository>();

            mockPhoneOrderRepository.Expects.One.Method(x => x.GetRecordCount()).WillReturn(5);
            phoneOrderService.SetPrivateField("phoneOrderRepository", mockPhoneOrderRepository.MockObject);

            String response = phoneOrderService.GetRecordCount();

            Assert.AreEqual("{\"result\":\"Done\",\"count\":5,\"orders\":null}", response);
        }
Example #15
0
        public void TestInitialize()
        {
            mockFactory = new MockFactory();
            Mock <IConnectionString> _connStringMock = mockFactory.CreateMock <IConnectionString>();

            _connStringMock.Stub.Out.GetProperty(x => x.ConnectionString).WillReturn(DATABASE_CONN_STRING);
            Mock <ISqlServerDatabase> _sqlPricingMock = mockFactory.CreateMock <ISqlServerDatabase>();

            _sqlPricingMock.Stub.Out.GetProperty(y => y.DatabaseConnString).WillReturn(_connStringMock.MockObject);

            _crudService = new DatabaseService(_sqlPricingMock.MockObject);
        }
Example #16
0
        public PrimeraVisitaServiceTest()
        {
            var mock = new MockFactory();

            _primeraVisitaRepositoryMock   = mock.CreateMock <IPrimeraVisitaRepository>();
            _calzadoHabitualRepositoryMock = mock.CreateMock <ICalzadoHabitualRepository>();
            _podologoRepositoryMock        = mock.CreateMock <IPodologoRepository>();
            _personaRepositoryMock         = mock.CreateMock <IPersonaRepository>();

            _primeraVisitaService = new PrimeraVisitaService(_primeraVisitaRepositoryMock.MockObject, _calzadoHabitualRepositoryMock.MockObject,
                                                             _personaRepositoryMock.MockObject, _podologoRepositoryMock.MockObject);
        }
Example #17
0
        public void Initialize()
        {
            CATEGORY_NAME        = "Przygodowa";
            BOOK_TITLE           = "Robinson";
            BOOK_AUTHORS         = "A I B";
            price                = 100;
            quantityMap          = new QuantityMap();
            quantity             = 10;
            quantityMap.Quantity = quantity;
            quantityMap.Id       = 1;
            category             = new Category();
            category.Name        = CATEGORY_NAME;
            bookType             = new BookType();
            bookType.Category    = category;
            bookType.Title       = BOOK_TITLE;
            bookType.Image       = null;
            bookType.Price       = price;
            bookType.Id          = 1;
            bookType.Authors     = BOOK_AUTHORS;
            bookTypeList         = new List <BookType>();
            categoryList         = new List <Category>();


            var bookInformationMock = _factory.CreateMock <IBooksInformationDao>();

            bis.BooksInformationDao = bookInformationMock.MockObject;

            bookInformationMock.Expects.One.MethodWith <BookType>(x => x.GetBookTypeById(-1)).WillReturn(null);
            bookInformationMock.Expects.One.MethodWith <BookType>(x => x.GetBookTypeById(bookType.Id)).WillReturn(bookType);
            bookInformationMock.Expects.One.MethodWith <IEnumerable <BookType> >(x => x.GetAllBooks())
            .WillReturn(bookTypeList);
            bookInformationMock.Expects.One.MethodWith <IList <Category> >(x => x.GetAllCategories())
            .WillReturn(categoryList);
            bookInformationMock.Expects.One.MethodWith <IEnumerable <BookType> >(x => x.GetBooksByCategoryId(category.Id))
            .WillReturn(bookTypeList);
            bookInformationMock.Expects.One.MethodWith <IEnumerable <BookType> >(x => x.GetBooksByCategoryId(-1))
            .WillReturn(null);


            var storehouseManagementMock = _factory.CreateMock <IStorehouseManagementDao>();

            sms.StorehouseManagementDao = storehouseManagementMock.MockObject;

            NMock.Actions.InvokeAction saveBookTypeAction = new NMock.Actions.InvokeAction(
                new Action(() => bookTypeList.Add(bookType)));

            storehouseManagementMock.Expects.Any.MethodWith(x => x.SaveBookType(bookType)).Will(saveBookTypeAction);

            NMock.Actions.InvokeAction saveCategoryAction = new NMock.Actions.InvokeAction(
                new Action(() => categoryList.Add(category)));

            storehouseManagementMock.Expects.Any.MethodWith(x => x.SaveCategory(category)).Will(saveCategoryAction);
        }
Example #18
0
        //[Ignore] //Testing class stuff
        public void ToStringTest()
        {
            Mock <TesterClass> mock = _factory.CreateMock <TesterClass>();

            string expected = "my string";

            mock.Expects.One.Method(_ => _.ToString()).WillReturn(expected);

            string s = mock.MockObject.ToString();

            Assert.AreEqual(expected, s);
        }
Example #19
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;
        }
        public static void ClassInitialize(TestContext context)
        {
            //INITIALIZED ALL THE MOCK OBJECTS NEEDED FOR TESTING
            MockFactory mockFactory = new MockFactory();

            _libraryConfigurationMocked       = mockFactory.CreateMock <IXXXLibraryConfiguration>();
            _IAircraftRecoverAndPersistMocked = mockFactory.CreateMock <IAircraftRecoverAndPersist>();

            //INITIALIZED SERVICE TO BE TESTED
            Sut = new SeatAssignment(_IAircraftRecoverAndPersistMocked.MockObject, _libraryConfigurationMocked.MockObject);

            //COMPLETE SCENARIO
            _IAircraftRecoverAndPersistMocked.Expects.One.Method(x => x.UpdateAircraft(default(Aircraft))).WithAnyArguments().WillReturn(false);
        }
Example #21
0
        public void TwoMocksTest()
        {
            var factory = new MockFactory();
            var mock    = factory.CreateMock <IParentInterface>();
            var mock2   = factory.CreateMock <IChildInterface>();

            mock.Expects.One.Method(_ => _.MethodVoid(null as Version)).With(new VersionMatcher());
            mock2.Expects.One.Method(_ => _.MethodVoid(null as OperatingSystem)).With(new OSMatcher());

            mock2.MockObject.MethodVoid(new OperatingSystem(PlatformID.Xbox, new Version(1, 1, 1, 1)));
            mock.MockObject.MethodVoid(new Version(1, 2, 2, 2));

            factory.VerifyAllExpectationsHaveBeenMet();
        }
        public void StubDeclaredExplicitly()
        {
            Mock <IDependency>        dependency        = mockFactory.CreateMock <IDependency>();
            Mock <IAnotherDependency> anotherDependency = mockFactory.CreateMock <IAnotherDependency>();

            dependency.Stub.Out.GetProperty(d => d.AnotherDependency).Will(Return.Value(anotherDependency.MockObject));

            using (mockFactory.Ordered())
            {
                anotherDependency.Expects.One.Method(_ => _.DoSomething());
            }

            dependency.MockObject.AnotherDependency.DoSomething();
        }
Example #23
0
        public void CanGetListOfOptions()
        {
            var mockDriver = mocks.CreateMock <IWebDriver>();
            var condition  = GetCondition(() => null, () => SOME_STRING);

            var wait = new WebDriverWait(new TickingClock(), mockDriver.MockObject, FIVE_SECONDS, ZERO_SECONDS);

            Assert.AreEqual(SOME_STRING, wait.Until(condition));

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
        public static void ClassInitialize(TestContext context)
        {
            //INITIALIZED ALL THE MOCK OBJECTS NEEDED FOR TESTING
            MockFactory mockFactory = new MockFactory();

            _libraryConfigurationMocked       = mockFactory.CreateMock <IXXXLibraryConfiguration>();
            _IAircraftRecoverAndPersistMocked = mockFactory.CreateMock <IAircraftRecoverAndPersist>();

            //INITIALIZED OBJECT CONTROLLER FOR UNIT TESTING
            Sut = new SeatAssignment(_IAircraftRecoverAndPersistMocked.MockObject, _libraryConfigurationMocked.MockObject);

            //COMPLETE SCENARIO
            _libraryConfigurationMocked.Expects.One.GetProperty(v => v.TimeSalesCloseBeforeFlight).WillReturn(2);
            _IAircraftRecoverAndPersistMocked.Expects.One.Method(x => x.UpdateAircraft(default(Aircraft))).WithAnyArguments().WillReturn(true);
        }
            public Mocks(MockFactory mockFactory)
            {
                SelectedClassProvider        = mockFactory.CreateMock <INullableValueProvider <IClassDeclaration> >();
                SelectedVariableProvider     = mockFactory.CreateMock <INullableValueProvider <IVariableDeclaration> >();
                IsClassHasTestClassAttribute = mockFactory.CreateMock <IValidator <IClassDeclaration> >();
                IsClassContainsMocksClass    = mockFactory.CreateMock <IValidator <IClassDeclaration> >();
                IsVariableNotNull            = mockFactory.CreateMock <IValidator <IVariableDeclaration> >();

                Sut = new CreateMocksClassContextActionAvailabilityValidator(
                    SelectedClassProvider.MockObject,
                    SelectedVariableProvider.MockObject,
                    IsClassHasTestClassAttribute.MockObject,
                    IsClassContainsMocksClass.MockObject,
                    IsVariableNotNull.MockObject);
            }
Example #26
0
        public void SaveInternetHandleTest()
        {
            //Create a MockFactory
            MockFactory factory = new MockFactory();

            //Create an instance of an IContactManagementDataSource Mock
            Mock <IContactManagementDataSource> dataSource = factory.CreateMock <IContactManagementDataSource>();

            //Create the ContactManagementBusinessLogic with 1 constructor argument
            ContactManagementBusinessLogic businessLogic = new ContactManagementBusinessLogic(dataSource.MockObject);

            int            contactId    = 1234;
            InternetHandle handle       = new InternetHandle(0, "*****@*****.**", "John Doe (Email)", HandleType.PersonalEmail);
            int            rowsAffected = 1;

            //Create an expectation that the dataSource will have its SaveInternetHandle method called
            //with contactId, and handle and will return the value of rowsAffected
            dataSource.Expects.One
            //note how the lambda specifies the method to call
            .MethodWith(d => d.SaveInternetHandle(contactId, handle)) //these are the parameters to match
            .WillReturn(rowsAffected);                                //the return value of the mocked method

            //Note how the expectation reads like an English sentence.
            //This is called *syntactic sugar*.

            //Call the method
            int i = businessLogic.SaveInternetHandle(contactId, handle);

            //Add the unit test assertion
            Assert.AreEqual(rowsAffected, i);
        }
Example #27
0
        public void setup()
        {
            List <Task> tasks = new List <Task>();

            task1             = new Task();
            task1.name        = "task1";
            task1.priority    = 1;
            task1.dateCreated = new DateTime(2013, 1, 1);
            task1.dueDate     = new DateTime(2014, 1, 1);

            task2             = new Task();
            task2.name        = "task2";
            task2.priority    = 2;
            task2.dateCreated = new DateTime(2012, 1, 1);
            task2.dueDate     = new DateTime(2013, 1, 1);

            task3             = new Task();
            task3.name        = "task1";
            task3.priority    = 3;
            task3.dateCreated = new DateTime(2011, 1, 1);
            task3.dueDate     = new DateTime(2012, 1, 1);

            tasks.Add(task1);
            tasks.Add(task2);
            tasks.Add(task3);


            mockFactory    = new MockFactory();
            mockRepository = mockFactory.CreateMock <IRepository <Task> >();
            mockRepository.Expects.One.MethodWith(r => r.getAllEntities()).WillReturn(tasks.AsQueryable());
            taskService = new TaskService(mockRepository.MockObject);
        }
        public void IfUserSetDebugOptionRequestAndErrorsShouldBeWritedToTrace()
        {
            var localName        = "sample.avi";
            var remoteName       = "TestPostAppendVideo.avi";
            var fullName         = Path.Combine(this.dataFolder, remoteName);
            var fullNameToAppend = Path.Combine(this.dataFolder, "videoForAppend.mp4");
            var destFileName     = Path.Combine(BaseTestOutPath, remoteName);

            AppendOptions options = new AppendOptions();

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));
            this.StorageApi.PutCreate(fullNameToAppend, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + "sample.mp4"));
            options.VideoToAppendPath = fullNameToAppend;

            var request = new PostAppendVideoRequest(remoteName, destFileName, options, this.dataFolder);
            var api     = this.GetDebugApi();

            var mockFactory       = new MockFactory();
            var traceListenerMock = mockFactory.CreateMock <TraceListener>();

            Trace.Listeners.Add(traceListenerMock.MockObject);

            traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("POST: http://api-dev.aspose.cloud/v1.1/video/TestPostAppendVideo.avi"));
            traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("Response 200: OK"));

            traceListenerMock.Expects.AtLeastOne.Method(p => p.WriteLine(string.Empty)).With(Is.Anything);

            // Act
            api.PostAppendVideo(request);

            // Assert
            mockFactory.VerifyAllExpectationsHaveBeenMet();
        }
        public void CreateTest()
        {
            var classMemberTextDeclarationsProvider1 = MockFactory.CreateMock <IProvider <string> >();
            var classMemberTextDeclarationsProvider2 = MockFactory.CreateMock <IProvider <string> >();
            var classMemberTextDeclarationsProviders = new List <IProvider <string> >
            {
                classMemberTextDeclarationsProvider1.MockObject,
                classMemberTextDeclarationsProvider2.MockObject
            };
            var sut = new ClassTextDeclarationProvider(classMemberTextDeclarationsProviders);

            var classMemberTextDeclarations =
                new List <string> {
                "SomeClassMemberDeclaration1", "SomeClassMemberDeclaration2"
            };

            classMemberTextDeclarationsProvider1.Expects.One
            .MethodWith(o => o.Get())
            .WillReturn(classMemberTextDeclarations[0]);
            classMemberTextDeclarationsProvider2.Expects.One
            .MethodWith(o => o.Get())
            .WillReturn(classMemberTextDeclarations[1]);
            var actualResult = sut.Get();

            // ToDo_AP: Возможно, стоит сравнивать без учета пробелов.
            Assert.AreEqual(ExpectedResult, actualResult);
        }
        public void DoNotIssueMoveIntoWater()
        {
            var mock = new MockFactory();
            var outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            using (mock.Ordered)
            {
                outputAdapterMock.Expects.One.MethodWith(adapter => adapter.NotifyEndOfTurn());
            }

            var trackerManager = new OwnAntTrackingManager(outputAdapterMock.MockObject);

            MapTile origin = GameContext.Map.At(3, 4);
            MapTile destination = origin.North;
            var ant = new Ant(origin);

            destination.State = TileState.Water;
            origin.CurrentAnt = ant;

            trackerManager.HasProcessedAllInputMoves();
            trackerManager.EnrollToMove(ant, destination);
            trackerManager.FinalizeAllMoves();

            Assert.IsNotNull(origin.CurrentAnt);
            Assert.AreEqual(ant, origin.CurrentAnt);

            mock.VerifyAllExpectationsHaveBeenMet();
        }
Example #31
0
 public void SetUp()
 {
     _mockFactory            = new MockFactory();
     _mockScrollViewScroller = _mockFactory.CreateMock <IScrollViewScroller>();
     _testScrollView         = new TestScrollView(_mockScrollViewScroller.MockObject);
     _scrollViewManager      = new ReactScrollViewManager();
 }
Example #32
0
        public void IfUserSetDebugOptionRequestAndErrorsShouldBeWritedToTrace()
        {
            var localName  = "test_multi_pages.docx";
            var remoteName = "IfUserSetDebugOptionRequestAndErrorsShouldBeWritedToTrace.docx";
            var fullName   = Path.Combine(this.dataFolder, remoteName);
            var request    = new DeleteFieldsRequest(remoteName, this.dataFolder);
            var api        = new WordsApi(new Configuration {
                ApiBaseUrl = BaseProductUri, AppKey = AppKey, AppSid = AppSID, DebugMode = true
            });

            var mockFactory       = new MockFactory();
            var traceListenerMock = mockFactory.CreateMock <TraceListener>();

            Trace.Listeners.Add(traceListenerMock.MockObject);

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(BaseTestContext.CommonFolder) + localName));

            traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("DELETE: http://api-dev.aspose.cloud/v1.1/words/IfUserSetDebugOptionRequestAndErrorsShouldBeWritedToTrace.docx/fields"));
            traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("Response 200: OK"));
            traceListenerMock.Expects.One.Method(p => p.WriteLine(string.Empty)).With(Is.StringContaining("{\"Code\":200,\"Status\":\"OK\"}"));

            traceListenerMock.Expects.AtLeastOne.Method(p => p.WriteLine(string.Empty)).With(Is.Anything);

            // Act
            api.DeleteFields(request);

            // Assert
            mockFactory.VerifyAllExpectationsHaveBeenMet();
        }
Example #33
0
        public void Test2()
        {
            var basketId1 = Guid.NewGuid();

            // crate mock
            var mock   = new MockFactory();
            var access = mock.CreateMock <IShoppingDataAccess>();

            var itemQueue = new Queue <BasketItem>();

            itemQueue.Enqueue(new BasketItem(1, 1));
            itemQueue.Enqueue(new BasketItem(2, 2));
            itemQueue.Enqueue(new BasketItem(2, 3));

            access.Expects.Any.Method(p => p.LoadBasketItems(basketId1)).
            WithAnyArguments().
            Will(Return.Value(itemQueue.ToArray()));

            // create basket1.
            var basket1    = new Basket(access.MockObject, basketId1);
            var totalPrice = basket1.CalculateSubTotal();

            Assert.AreEqual(6, totalPrice);

            // create basket2
            var basketId2 = Guid.NewGuid();
            var basket2   = new Basket(access.MockObject, basketId2);

            totalPrice = basket2.CalculateSubTotal();
            Assert.AreEqual(6, totalPrice);
        }
Example #34
0
        public void Init()
        {
            mockRestClient = mockFactory.CreateMock <IRestClient>();
            mockRestClient.Expects.AtLeastOne.GetProperty(_ => _.Timeout).WillReturn(60000);
            mockRestClient.Expects.AtLeastOne.GetProperty(_ => _.UserAgent).WillReturn("asdasd");
            mockRestClient.Expects.AtLeastOne.SetPropertyTo(_ => _.Timeout   = 60000);
            mockRestClient.Expects.AtLeastOne.SetPropertyTo(_ => _.UserAgent = "asdasd");

            eventTypesResponse = new RestResponse
            {
                StatusCode = System.Net.HttpStatusCode.OK,
                Content    = @"[  { ""name"": ""net.authorize.customer.created"" },
                { ""name"": ""net.authorize.customer.deleted"" },
                { ""name"": ""net.authorize.customer.updated"" },
                { ""name"": ""net.authorize.customer.paymentProfile.created"" },
                { ""name"": ""net.authorize.customer.paymentProfile.deleted"" },
                { ""name"": ""net.authorize.customer.paymentProfile.updated"" },
                { ""name"": ""net.authorize.customer.subscription.cancelled"" },
                { ""name"": ""net.authorize.customer.subscription.created"" },
                { ""name"": ""net.authorize.customer.subscription.expiring"" },
                { ""name"": ""net.authorize.customer.subscription.suspended"" },
                { ""name"": ""net.authorize.customer.subscription.terminated"" },
                { ""name"": ""net.authorize.customer.subscription.updated"" },
                { ""name"": ""net.authorize.payment.authcapture.created"" },
                { ""name"": ""net.authorize.payment.authorization.created"" },
                { ""name"": ""net.authorize.payment.capture.created"" },
                { ""name"": ""net.authorize.payment.fraud.approved"" },
                { ""name"": ""net.authorize.payment.fraud.declined"" },
                { ""name"": ""net.authorize.payment.fraud.held"" },
                { ""name"": ""net.authorize.payment.priorAuthCapture.created"" },
                { ""name"": ""net.authorize.payment.refund.created"" },
                { ""name"": ""net.authorize.payment.void.created""  }]"
            };
        }
        public void IsLoginOK_WhenLoggerThrows_CallsWebService()
        {
            var fac = new MockFactory();
            var webservice = fac.CreateMock<IWebService>();
            webservice.Expects.AtLeastOne.Method(_ => _.Write(null)).With(NMock.Is.StringContaining("s"));

            var logger = fac.CreateMock<ILogger>();
            logger.Stub.Out.Method(_ => _.Write(null))
                .WithAnyArguments()
                .Will(Throw.Exception(new Exception("dude this is fake")));

            var lm =
                new LoginManagerWithMockAndStub(logger.MockObject,webservice.MockObject);
            lm.IsLoginOK("a", "b");

            webservice.VerifyAllExpectations();
        }
        public void IsLoginOK_WhenCalled_WritesToLog()
        {
            var factory = new MockFactory();
            Mock<ILogger> logger = factory.CreateMock<ILogger>();
            logger.Expects.One.Method(_ => _.Write(null)).WithAnyArguments();

            var lm = new LoginManagerWithMock(logger.MockObject);
            lm.IsLoginOK("a", "b");

            logger.VerifyAllExpectations();
        }
        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 EnsureThatEverythingIsTrackedCorrectly()
        {
            var mock = new MockFactory();
            Mock<IGameOutputAdapter> outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            outputAdapterMock.Expects.AtLeastOne.MethodWith(x => x.NotifyReady());
            outputAdapterMock.Expects.AtLeastOne.MethodWith(x => x.NotifyEndOfTurn());

            var gameManager = new GameManager(outputAdapterMock.MockObject);
            var inputInterpreter = new InputInterpreter(gameManager);

            inputInterpreter.Interpret("turn 0");
            inputInterpreter.Interpret("rows 10");
            inputInterpreter.Interpret("cols 10");
            inputInterpreter.Interpret("ready");

            inputInterpreter.Interpret("turn 1");
            inputInterpreter.Interpret("a 0 5 0");
            inputInterpreter.Interpret("go");

            Ant initAnt = (from row in Enumerable.Range(0, GameContext.Map.Rows)
                           from col in Enumerable.Range(0, GameContext.Map.Columns)
                           let tile = GameContext.Map.At(row, col)
                           where tile.CurrentAnt != null
                           select tile.CurrentAnt
                          ).Single();

            initAnt.MovementStrategy = new MoveDirection(initAnt, Direction.South);

            for (int turn = 2; turn < 10; turn++)
            {
                var expectedRow = turn - 2;
                var expectedColumn = initAnt.CurrentPosition.Column;

                inputInterpreter.Interpret("turn " + turn);
                inputInterpreter.Interpret(string.Format("a {0} {1} 0", expectedRow, expectedColumn));

                outputAdapterMock.Expects.One
                    .MethodWith(adapter => adapter.MoveAnt(expectedRow, expectedColumn, Direction.South));

                inputInterpreter.Interpret("go");

                Assert.IsTrue(initAnt.MovementStrategy is MoveDirection);
            }

            mock.VerifyAllExpectationsHaveBeenMet();
        }
        public void EnsureMovesAreIssued()
        {
            var mock = new MockFactory();
            Mock<IGameOutputAdapter> outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            outputAdapterMock.Expects.One.MethodWith(x => x.NotifyReady());
            outputAdapterMock.Expects.One.MethodWith(x => x.NotifyEndOfTurn());

            var gameManager = new GameManager(outputAdapterMock.MockObject);
            var turnResults = new TurnState();

            turnResults.Ants.Add(new TurnState.Point(3, 3));

            gameManager.RulesNotification(new GameRules {MapColumns = 10, MapRows = 10});
            gameManager.DoMoves(turnResults);

            mock.VerifyAllExpectationsHaveBeenMet();
        }
 public void Before()
 {
     mockery = new MockFactory();
     sniperListener = mockery.CreateMock<ISniperListener>();
 }
 public void SetUp()
 {
     factory = new MockFactory();
     loopTracker = factory.CreateMock<AbstractLoopTracker>();
     sceneFactory = factory.CreateMock<AbstractSceneFactory>();
 }
Example #42
0
 public void SetUp()
 {
     factory = new MockFactory();
     sprite = factory.CreateMock<Sprite>();
 }
 public void Before()
 {
     mockery = new MockFactory();
     auctionEventListener = mockery.CreateMock<IAuctionEventListener>();
     auctionMessageTranslator = new AuctionMessageTranslator(auctionEventListener.MockObject);
 }
Example #44
0
 public void SetUp()
 {
     factory = new MockFactory();
     sounds = factory.CreateMock<MockSounds>();
     tracker = new LoopTracker(sounds.MockObject);
 }
        public void TwoAntsCannotMoveIntoSameTile()
        {
            var mock = new MockFactory();
            var outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            using (mock.Ordered)
            {
                outputAdapterMock.Expects.One
                    .Method(adapter => adapter.MoveAnt(0, 0, 0))
                    .WithAnyArguments();

                outputAdapterMock.Expects.One.MethodWith(adapter => adapter.NotifyEndOfTurn());
            }

            var trackerManager = new OwnAntTrackingManager(outputAdapterMock.MockObject);

            MapTile origin1 = GameContext.Map.At(3, 4);
            MapTile destination = origin1.North;
            MapTile origin2 = destination.North;
            var ant1 = new Ant(origin1);
            var ant2 = new Ant(origin2);

            origin1.CurrentAnt = ant1;
            origin2.CurrentAnt = ant2;

            trackerManager.HasProcessedAllInputMoves();
            trackerManager.EnrollToMove(ant1, destination);
            trackerManager.EnrollToMove(ant2, destination);
            trackerManager.FinalizeAllMoves();

            trackerManager.AntHasMovedTo(destination.Row, destination.Column);

            mock.VerifyAllExpectationsHaveBeenMet();
        }
        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()
        {
            _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;
        }
        public void SimpleTrackingCase()
        {
            var mock = new MockFactory();
            var outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            using (mock.Ordered)
            {
                outputAdapterMock.Expects.One
                    .Method(adapter => adapter.MoveAnt(0, 0, 0))
                    .WithAnyArguments();

                outputAdapterMock.Expects.One.MethodWith(adapter => adapter.NotifyEndOfTurn());
            }

            var trackerManager = new OwnAntTrackingManager(outputAdapterMock.MockObject);

            MapTile origin = GameContext.Map.At(3, 4);
            MapTile destination = origin.North;
            var ant = new Ant(origin);

            origin.CurrentAnt = ant;

            trackerManager.HasProcessedAllInputMoves();
            trackerManager.EnrollToMove(ant, destination);
            trackerManager.FinalizeAllMoves();

            Assert.IsNull(origin.CurrentAnt);

            trackerManager.AntHasMovedTo(destination.Row, destination.Column);

            Assert.IsNull(origin.CurrentAnt);
            Assert.AreEqual(ant, destination.CurrentAnt);

            mock.VerifyAllExpectationsHaveBeenMet();
        }
 public void SetUp()
 {
     _mockFactory = new MockFactory();
     _mockInvocationHandler = _mockFactory.CreateMock<IInvocationHandler>();
     _module = new TestJavaScriptModule();
 }
Example #50
0
 public void SetUp()
 {
     factory = new MockFactory();
     camera = factory.CreateMock<Camera>();
     inputReturningTouch = inputReturningMockTouch();
 }