public void SetUp()
        {
            this.mockery = new Mockery();

            this.validationFactory = this.mockery.NewMock<IValidationFactory>();
            Stub.On(this.validationFactory).Method("CreateValidationResult").With(true).Will(Return.Value(new ValidationResult(true)));
            Stub.On(this.validationFactory).Method("CreateValidationResult").With(false).Will(Return.Value(new ValidationResult(false)));
        }
예제 #2
0
        public void GetAvailableValuesTest()
        {
            const uint type = 123;

            int[] values = new int[] { 1, 2, 10 };
            EnumValueCollection collection = new EnumValueCollection();

            collection.Add(new EnumValue(1, "1", 0));
            collection.Add(new EnumValue(2, "2", 0));
            collection.Add(new EnumValue(3, "3", 0));
            collection.Add(new EnumValue(10, "10", 0));

            Mockery mockery = new Mockery();
            ICamera camera  = (ICamera)mockery.NewMock(typeof(ICamera));

            Expect.Once.On(camera).Method("GetAvailableValues").With(type).Will(Return.Value(values));

            EnumValueCollection result = EnumValue.GetListFrom(camera, type, collection);

            Assert.AreEqual(values.Length, result.Count);
            Assert.AreEqual(values[0], result[1].Value);
            Assert.AreEqual(values[1], result[2].Value);
            Assert.AreEqual(values[2], result[10].Value);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
예제 #3
0
 public void SetUp()
 {
     mocks = new Mockery();
     mockDriver = mocks.NewMock<ISearchContext>();
     mockElement = mocks.NewMock<IWebElement>();
     mockExplicitDriver = mocks.NewMock<IWebDriver>();
 }
예제 #4
0
        public void FindElementTwoBy()
        {
            var mocks  = new Mockery();
            var driver = mocks.NewMock <IAllDriver>();

            var elem1 = mocks.NewMock <IAllElement>();
            var elem2 = mocks.NewMock <IAllElement>();
            var elem3 = mocks.NewMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1, elem2
            }.AsReadOnly();
            var elems23 = new List <IWebElement> {
                elem2, elem3
            }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("photo").Will(Return.Value(elems23));

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            // findElement
            Assert.That(by.FindElement(driver), Is.EqualTo(elem2));

            //findElements
            var result = by.FindElements(driver);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2));

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
예제 #5
0
        public void FindElementDisjunct()
        {
            var mocks  = new Mockery();
            var driver = mocks.NewMock <IAllDriver>();

            var elem1 = mocks.NewMock <IAllElement>();
            var elem2 = mocks.NewMock <IAllElement>();
            var elem3 = mocks.NewMock <IAllElement>();
            var elem4 = mocks.NewMock <IAllElement>();
            var elems12 = new List <IWebElement> {
                elem1, elem2
            }.AsReadOnly();
            var elems34 = new List <IWebElement> {
                elem3, elem4
            }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("photo").Will(Return.Value(elems34));

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            Assert.Throws <NoSuchElementException>(() => by.FindElement(driver));

            var result = by.FindElements(driver);

            Assert.That(result.Count, Is.EqualTo(0));
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
예제 #6
0
        public void TestAppstoreShopListParseMechanics()
        {
            string xml =
            @"<roar tick=""130695522924"">
                <appstore>
                    <shop_list>
                        <shopitem product_identifier=""someidentifier"" label=""A label"">
                            <modifiers>
                                <grant_item ikey=""item_ikey_1""/>
                                <grant_stat ikey=""item_stat"" type=""some type"" value=""7""/>
                            </modifiers>
                        </shopitem>
                    </shop_list>
                </appstore>
            </roar>";

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.Appstore.ShopList shop_list_parser = new Roar.DataConversion.Responses.Appstore.ShopList();

            Mockery mockery = new Mockery();
            Roar.DataConversion.IXCRMParser ixcrm_parser = mockery.NewMock<Roar.DataConversion.IXCRMParser>();
            shop_list_parser.ixcrm_parser = ixcrm_parser;
            IList<Roar.DomainObjects.Modifier> modifier_list = new List<Roar.DomainObjects.Modifier>();
            Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(nn.SelectSingleNode("./appstore/shop_list/shopitem/modifiers")).Will(Return.Value(modifier_list));

            ShopListResponse response = shop_list_parser.Build(nn);

            mockery.VerifyAllExpectationsHaveBeenMet();

            Assert.IsNotNull(response);
            Assert.AreEqual(response.shop_list.Count, 1);
            Assert.AreEqual(response.shop_list[0].product_identifier, "someidentifier");
            Assert.AreEqual(response.shop_list[0].label, "A label");
            Assert.AreEqual(response.shop_list[0].modifiers, modifier_list);
        }
예제 #7
0
        public void ShouldResolveDependencyTest()
        {
            DependencyManager     dependencyManager;
            Mockery               mockery;
            IDependencyResolution mockDependencyResolution;
            Type   targetType;
            string selectorKey;
            object value;

            mockery = new Mockery();
            mockDependencyResolution = mockery.NewMock <IDependencyResolution>();

            Expect.Once.On(mockDependencyResolution).Method("Resolve").WithNoArguments().Will(Return.Value(1));

            dependencyManager = new DependencyManager();
            targetType        = typeof(object);
            selectorKey       = "x";

            dependencyManager.AddResolution(targetType, selectorKey, mockDependencyResolution);
            value = dependencyManager.ResolveDependency(targetType, selectorKey);

            Assert.IsNotNull(value);
            Assert.AreEqual(1, value);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
예제 #8
0
		public void TestGetHandlerFor()
		{
			Mockery mocks;
			IOTAProject mockProject;
			IUser mockUser;
			IGenerator mockGenerator;
			mocks = new Mockery();
			mockProject = mocks.NewMock<IOTAProject>();
			mockUser = mocks.NewMock<IUser>();
			mockGenerator = mocks.NewMock<IGenerator>();
			//TODO: use Mock objects.
			string fileName = Path.Combine(Path.GetTempPath(), "test.dproj");
			Expect.AtLeast(3).On(mockProject).GetProperty("FileName").
				Will(Return.Value(fileName));
			Expect.Once.On(mockProject).Method("Save").WithAnyArguments().Will(Return.Value(true));
			Expect.Once.On(mockProject).Method("AddFile").WithAnyArguments().Will(Return.Value(null));
			Expect.Once.On(mockUser).Method("ProvideKeyFile").Will(Return.Value(null));
			Expect.Once.On(mockGenerator).Method("GenerateKey").WithAnyArguments().Will(Return.Value(true));
			IHandler handler = HandlerFactory.GetHandlerFor(mockProject);
			Assert.IsTrue(handler is Manner20UnsignedHandler);
			(handler as Manner20UnsignedHandler).User = mockUser;
			(handler as Manner20UnsignedHandler).Generator = mockGenerator;
			handler.Handle();
			IHandler handler2 = HandlerFactory.GetHandlerFor(mockProject);
			Assert.IsTrue(handler2 is Manner20SignedHandler);
			mocks.VerifyAllExpectationsHaveBeenMet();
		}
 public void beforTest()
 {
     mockery = new Mockery();
     view = mockery.NewMock<IPlaylistCreatorView>();
     task = mockery.NewMock<IPlaylistCreatorTask>();
     presenter = new PlaylistCreatorPresenter(view, task);
 }
예제 #10
0
        public void TestGetCommentsListForUser6()
        {
            Console.WriteLine("Before CommentLists - TestGetCommentsListForUser6");
            //Create the mocked inputcontext
            Mockery mock = new Mockery();
            IInputContext mockedInputContext = mock.NewMock<IInputContext>();
            //XmlDocument siteconfig = new XmlDocument();
            //siteconfig.LoadXml("<SITECONFIG />");
            ISite site = mock.NewMock<ISite>();
            //Stub.On(site).GetProperty("SiteConfig").Will(Return.Value(siteconfig.FirstChild));
            Stub.On(site).GetProperty("SiteID").Will(Return.Value(1));

            User user = new User(mockedInputContext);
            Stub.On(mockedInputContext).GetProperty("ViewingUser").Will(Return.Value(user));
            Stub.On(mockedInputContext).GetProperty("CurrentSite").Will(Return.Value(site));

            // Create the stored procedure reader for the CommentList object
            IInputContext context = DnaMockery.CreateDatabaseInputContext();
            using (IDnaDataReader reader = context.CreateDnaDataReader("getusercommentsstats"))
            {
                using (IDnaDataReader reader2 = context.CreateDnaDataReader("fetchgroupsandmembers"))
                {
                    Stub.On(mockedInputContext).Method("CreateDnaDataReader").With("getusercommentsstats").Will(Return.Value(reader));
                    Stub.On(mockedInputContext).Method("CreateDnaDataReader").With("fetchgroupsandmembers").Will(Return.Value(reader2));

                    // Create a new CommentsList object and get the list of comments
                    CommentsList testCommentsList = new CommentsList(mockedInputContext);
                    Assert.IsTrue(testCommentsList.CreateRecentCommentsList(6, 1, 0, 20));
                }
            }
            Console.WriteLine("After CommentLists - TestGetCommentsListForUser6");
        }
예제 #11
0
        //[TestMethod]
        public void greatChangePriceChooserTest()
        {
            Mockery mocks = new Mockery();
            IDefaultHttpClient dhcMock = mocks.NewMock<IDefaultHttpClient>();

            Expect.Once.On(dhcMock).Method("SendHttpGetAndReturnResponseContent").With("http://parafia.biz/relics/market_show/70").Will(Return.Value(TestData.ParafiaBizMarketGreatChangeContent));

            String responseContent = dhcMock.SendHttpGetAndReturnResponseContent("http://parafia.biz/relics/market_show/70");

            HtmlNode.ElementsFlags.Remove("option");
            HtmlNodeCollection optionsNode = HtmlUtils.GetNodesCollectionByXPathExpression(responseContent, "//select[@id='market_id']/option");

            Random rand = new Random();
            int value = 10000;
            int counter;
            do
            {
                counter = 0;
                foreach (HtmlNode node in optionsNode)
                {
                    String txtValueForOption = node.InnerText;
                    if (!String.IsNullOrEmpty(txtValueForOption))
                    {
                        int valueForOption = int.Parse(Parafia.MainUtils.removeAllNotNumberCharacters(txtValueForOption));
                        if (valueForOption == value)
                            counter++;
                    }
                }
                if (counter != 0)
                    value = rand.Next(11642 - 100, 11642);
            }
            while (counter != 0);
        }
예제 #12
0
 private void SetupGiven(ref Mockery mocks, ref SimplestPossibleWorld world)
 {
     IGiven given = (IGiven)mocks.NewMock<IGiven>();
     Expect.AtLeast(1).On(given).Method("Setup").With(world);
     List<IGiven> GivenCollection = new List<IGiven>();
     GivenCollection.Add(given);
 }
예제 #13
0
        public void FindElementTwoBy()
        {
            var mocks = new Mockery();
            var driver = mocks.NewMock<IAllDriver>();

            var elem1 = mocks.NewMock<IAllElement>();
            var elem2 = mocks.NewMock<IAllElement>();
            var elem3 = mocks.NewMock<IAllElement>();
            var elems12 = new List<IWebElement> { elem1, elem2 }.AsReadOnly();
            var elems23 = new List<IWebElement> { elem2, elem3 }.AsReadOnly();

            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("photo").Will(Return.Value(elems23));

            var by = new ByAll(By.Name("cheese"), By.Name("photo"));

            // findElement
            Assert.That(by.FindElement(driver), Is.EqualTo(elem2));

            //findElements
            var result = by.FindElements(driver);
            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result[0], Is.EqualTo(elem2));

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
예제 #14
0
        public void ShouldCreateInstanceWithCacheKeyAndInvokeDynamicFactoryTest()
        {
            Mockery mockery;
            MockProxyFactory factory;
            IMockObject objectContract;
            MockProxyFactory.IInvokeDynamicFactory mockInvokeDynamicFactory;
            IDynamicInvocation mockDynamicInvocation;
            MethodInfo invokedMethodInfo;

            mockery = new Mockery();
            mockDynamicInvocation = mockery.NewMock<IDynamicInvocation>();
            mockInvokeDynamicFactory = mockery.NewMock<MockProxyFactory.IInvokeDynamicFactory>();

            invokedMethodInfo = (MethodInfo)MemberInfoProxy<IDisposable>.GetLastMemberInfo(exec => exec.Dispose());

            Expect.Once.On(mockInvokeDynamicFactory).Method("GetDynamicInvoker").With("myCacheKey", typeof(IMockObject)).Will(Return.Value(mockDynamicInvocation));

            factory = new MockProxyFactory();

            Assert.IsNotNull(factory);

            objectContract = factory.CreateInstance("myCacheKey", mockInvokeDynamicFactory);
            Assert.IsNotNull(objectContract);

            factory.Dispose();

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
예제 #15
0
        public void TestCheckLoadAllowedURLListData()
        {
            Console.WriteLine("Before TestCheckLoadAllowedURLListData");

            //Create the mocked inputcontext
            Mockery mock = new Mockery();
            IInputContext mockedInputContext = DnaMockery.CreateDatabaseInputContext();
            //XmlDocument siteconfig = new XmlDocument();
            //siteconfig.LoadXml("<SITECONFIG />");
            ISite site = mock.NewMock<ISite>();
            //Stub.On(site).GetProperty("SiteConfig").Will(Return.Value(siteconfig.FirstChild));
            Stub.On(site).GetProperty("SiteID").Will(Return.Value(1));

            User user = new User(mockedInputContext);
            Stub.On(mockedInputContext).GetProperty("ViewingUser").Will(Return.Value(user));
            Stub.On(mockedInputContext).GetProperty("CurrentSite").Will(Return.Value(site));

            // Create the stored procedure reader for the UITemplate object
            using (IDnaDataReader reader = mockedInputContext.CreateDnaDataReader("getallallowedurls"))
            {
                Stub.On(mockedInputContext).Method("CreateDnaDataReader").With("getallallowedurls").Will(Return.Value(reader));
                AllowedURLs allowedURLs = new AllowedURLs();
                allowedURLs.LoadAllowedURLLists(mockedInputContext);
                Assert.IsTrue(allowedURLs.DoesAllowedURLListContain(1, "www.bbc.co.uk"), "Does not report that it contains the bbc web address");
            }
            Console.WriteLine("After TestCheckLoadAllowedURLListData");
        }
예제 #16
0
        public void ShouldClearTypeResolutionsTest()
        {
            DependencyManager     dependencyManager;
            Mockery               mockery;
            IDependencyResolution mockDependencyResolution;
            Type   targetType;
            string selectorKey;
            bool   result;

            mockery = new Mockery();
            mockDependencyResolution = mockery.NewMock <IDependencyResolution>();

            dependencyManager = new DependencyManager();
            targetType        = typeof(object);
            selectorKey       = "ddd";

            result = dependencyManager.ClearTypeResolutions(targetType);

            Assert.IsFalse(result);

            dependencyManager.AddResolution(targetType, selectorKey, mockDependencyResolution);

            result = dependencyManager.ClearTypeResolutions(targetType);

            Assert.IsTrue(result);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
예제 #17
0
        public void InitError()
        {
            var mocks = new Mockery();
            var api   = mocks.NewMock <IBluetopiaApi>();

            // Second time after try-kill BTExplorer.exe
            Expect.Exactly(2).On(api).Method("BSC_Initialize")
            .WithAnyArguments()      // TO-DO
            .Will(Return.Value((int)BluetopiaError.UNSUPPORTED_PLATFORM_ERROR));
            //----
            try {
                BluetopiaTesting.HackAllowShutdownCall(api);
                BluetopiaFactory fcty = new BluetopiaFactory(api);
                Assert.Fail("should have thrown!");
            } catch (BluetopiaSocketException ex) {
                Assert.AreEqual((int)BluetopiaError.UNSUPPORTED_PLATFORM_ERROR, ex.BluetopiaErrorCode, "BluetopiaErrorCode");
                Assert.AreEqual(BluetopiaError.UNSUPPORTED_PLATFORM_ERROR.ToString(), ex.BluetopiaError, "BluetopiaError");
                Assert.AreEqual(
                    // was: "An operation was attempted on something that is not a socket"
                    "The attempted operation is not supported for the type of object referenced"
                    + " (Bluetopia: UNSUPPORTED_PLATFORM_ERROR (-101)).",
                    ex.Message, "Message");
            }
            //
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
예제 #18
0
        public void FindElementTwoByEmptyChild()
        {
            Mockery    mocks  = new Mockery();
            IAllDriver driver = mocks.NewMock <IAllDriver>();

            IAllElement elem1   = mocks.NewMock <IAllElement>();
            IAllElement elem2   = mocks.NewMock <IAllElement>();
            IAllElement elem5   = mocks.NewMock <IAllElement>();
            var         elems   = new List <IWebElement>().AsReadOnly();
            var         elems12 = new List <IWebElement>()
            {
                elem1, elem2
            }.AsReadOnly();
            var elems5 = new List <IWebElement>()
            {
                elem5
            }.AsReadOnly();

            Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            Expect.Once.On(elem1).Method("FindElements").With(By.Name("photo")).Will(Return.Value(elems));
            Expect.Once.On(elem2).Method("FindElements").With(By.Name("photo")).Will(Return.Value(elems5));

            ByChained by = new ByChained(By.Name("cheese"), By.Name("photo"));

            Assert.That(by.FindElement(driver), Is.EqualTo(elem5));
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
 public void beforTest()
 {
     mockery = new Mockery();
     view = mockery.NewMock<ITrackView>();
     dao = mockery.NewMock<ITrackDao>();
     presenter = new TrackPresenter(view, dao);
 }
        //TODO: Talk with Mark H to understand the purpose of this test.
        //Why is this relevent specifically to ContactFormListBuilder for example?
        //Is it not a more generic unit test for base functionality?
        public void GivenCallingProcessInputParametersShouldSetSkipAndShowVariables()
        {
            Mockery mock = new Mockery();
            IInputContext mockedInputContext = mock.NewMock<IInputContext>();
            ISite mockedSite = mock.NewMock<ISite>();

            Stub.On(mockedSite).GetProperty("SiteID").Will(Return.Value(1));
            Stub.On(mockedInputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));

            ContactFormListBuilder_Accessor privateAccessor = new ContactFormListBuilder_Accessor(mockedInputContext);

            int expectedShow = 20;
            int expectedSkip = 10;
            int expectedSiteID = 66;

            Stub.On(mockedInputContext).Method("DoesParamExist").With("skip", "Items to skip").Will(Return.Value(true));
            Stub.On(mockedInputContext).Method("DoesParamExist").With("show", "Items to show").Will(Return.Value(true));
            Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("skip", "Items to skip").Will(Return.Value(expectedSkip));
            Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("show", "Items to show").Will(Return.Value(expectedShow));
            Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("dnasiteid", "The specified site").Will(Return.Value(expectedSiteID));

            privateAccessor.ProcessInputParameters();

            Assert.AreEqual(privateAccessor.show, expectedShow);
            Assert.AreEqual(privateAccessor.skip, expectedSkip);
            Assert.AreEqual(privateAccessor.requestedSiteID, expectedSiteID);
        }
예제 #21
0
        /// <summary>Mocks a subscriber for the events of a list</summary>
        /// <param name="mockery">Mockery through which the mock will be created</param>
        /// <param name="list">List to mock an event subscriber for</param>
        /// <returns>The mocked event subscriber</returns>
        private static IListSubscriber mockSubscriber(Mockery mockery, ListControl list)
        {
            IListSubscriber mockedSubscriber = mockery.NewMock <IListSubscriber>();

            list.SelectionChanged += new EventHandler(mockedSubscriber.SelectionChanged);
            return(mockedSubscriber);
        }
 protected void SetUp()
 {
     mocks                  = new Mockery();
     mockMessageFile        = mocks.NewMock <IFile>();
     mockFileSystem         = mocks.NewMock <IFileSystem>();
     testFileRemoteReceiver = new FileRemoteReceiver(messageFilePath, lockFilePath, 1000, new ConsoleApplicationLogger(LogLevel.Warning, '|', "  "), new NullMetricLogger(), mockMessageFile, mockFileSystem);
 }
예제 #23
0
 protected void SetUp()
 {
     mocks = new Mockery();
     mockUnderlyingRemoteReceiver   = mocks.NewMock <IRemoteReceiver>();
     mockApplicationLogger          = mocks.NewMock <IApplicationLogger>();
     testRemoteReceiverDecompressor = new RemoteReceiverDecompressor(mockUnderlyingRemoteReceiver, mockApplicationLogger);
 }
예제 #24
0
 public void MyTestInitialize()
 {
     m_mocks          = new Mockery();
     m_twitterExecute = m_mocks.NewMock <ITwitterExecute>();
     m_oAuthTwitter   = m_mocks.NewMock <IOAuthTwitter>();
     m_ctx            = new TwitterContext(m_twitterExecute);
 }
예제 #25
0
        public void SimpleInstantiation()
        {
            Mockery mocks = new Mockery();

            IDataReader reader = mocks.NewMock<IDataReader>();

            Expect.Once.On(reader)
                .Method("Read")
                .Will(Return.Value(true));

            Expect.Once.On(reader)
                .Get["employee_id"]
                .Will(Return.Value(12));

            Expect.Once.On(reader)
                .Get["employee_name"]
                .Will(Return.Value("Alice"));

            Expect.Once.On(reader)
                .Method("Read")
                .Will(Return.Value(false));

            ObjectBuilder<Employee> builder = new ObjectBuilder<Employee>(reader);

            Employee alice = builder.Single();

            Assert.AreEqual(12, alice.ID);
            Assert.AreEqual("Alice", alice.Name);
        }
        public void TestEmailSendMailOrSystemMessage()
        {
            //Create the mocked inputcontext
            Mockery mock = new Mockery();
            IInputContext context = DnaMockery.CreateDatabaseInputContext();

            //XmlDocument siteconfig = new XmlDocument();
            //siteconfig.LoadXml("<SITECONFIG />");

            // Create a mocked site for the context
            ISite mockedSite = mock.NewMock<ISite>();
            //Stub.On(mockedSite).GetProperty("SiteConfig").Will(Return.Value(siteconfig.FirstChild));
            Stub.On(mockedSite).GetProperty("SiteID").Will(Return.Value(1));
            Stub.On(mockedSite).GetProperty("SiteName").Will(Return.Value("h2g2"));
            Stub.On(mockedSite).GetProperty("ModClassID").Will(Return.Value(1));

            Stub.On(context).GetProperty("CurrentSite").Will(Return.Value(mockedSite));

            IUser mockedUser = mock.NewMock<IUser>();
            Stub.On(mockedUser).GetProperty("UserID").Will(Return.Value(1090558354));

            Stub.On(context).GetProperty("ViewingUser").Will(Return.Value(mockedUser));
            Stub.On(context).Method("GetSiteRoot").Will(Return.Value("dnadev.national.core.bbc.co.uk:8081/dna/"));
            Stub.On(context).Method("SendMailOrSystemMessage");

            MessageBoardStatistics mbStats = new MessageBoardStatistics(context);
            mbStats.SendMessageBoardStatsEmail((new DateTime(2008, 1, 1)), "*****@*****.**", "*****@*****.**" );


        }
예제 #27
0
        public void StartUp()
        {
            Console.WriteLine("StartUp()");
            if (!_setupRun)
            {
                Console.WriteLine("Setting up");


                string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
                BBC.Dna.AppContext.OnDnaStartup(rootPath);

                //Create the mocked inputcontext
                Mockery mock = new Mockery();
                _context = DnaMockery.CreateDatabaseInputContext();

                // Create a mocked site for the context
                ISite mockedSite = DnaMockery.CreateMockedSite(_context, 1, "h2g2", "h2g2", true, "comment");
                Stub.On(_context).GetProperty("CurrentSite").Will(Return.Value(mockedSite));
                Stub.On(mockedSite).GetProperty("ModClassID").Will(Return.Value(1));

                Stub.On(_context).Method("FileCacheGetItem").Will(Return.Value(false));
                Stub.On(_context).Method("FileCachePutItem").Will(Return.Value(false));

                // Initialise the profanities object
                var p = new ProfanityFilter(DnaMockery.CreateDatabaseReaderCreator(), DnaDiagnostics.Default, CacheFactory.GetCacheManager(), null, null);
                BBC.Dna.User user = new BBC.Dna.User(_context);
                Stub.On(_context).GetProperty("ViewingUser").Will(Return.Value(user));
                
                _setupRun = true;
            }
            Console.WriteLine("Finished StartUp()");
        }
예제 #28
0
        public void Setup()
        {
            mocks             = new Mockery();
            conexion_mockeada = mocks.NewMock <IConexionBD>();
            tabla_vacia       = new TablaDeDatos();

            source_javier_lurgo = @"    Nro_Documento   |id_interna |Nombre	    |Apellido   |Cuil_Nro  
                                        29193500        |205171     |Javier     |Lurgo	    |20-29193500-2";

            source_imagenes_del_legajo_de_javier_lurgo = @"    id_imagen    |nro_folio
                                                                1           |0";

            source_documentos_de_javier_lurgo = @"      tabla       |id     |JUR	                            |ORG                            |TIPO               |FOLIO	    |fecha_comunicacion         |Fecha_Hasta
                                                        curriculums |221    |Ministerio de desarrollo social	|Direccion de recursos humanos	|curriculum         |00-000/000	|2012-05-21 00:00:00.000	|1900-01-01 00:00:00.000"    ;

            source_imagenes_del_documento_de_javier_lurgo = @"    id_imagen
                                                                7
                                                                8";

            source_id_categoria_del_documento_de_javier_lurgo = @"      id_categoria
                                                                        54";

            source_imagen_10                          = @"      nombre_imagen       |bytes_imagen
                                        imagen10            |R0lGODlhUAAPAKIAAAsLav///88PD9WqsYmApmZmZtZfYmdakyH5BAQUAP8ALAAAAABQAA8AAAPbWLrc/jDKSVe4OOvNu/9gqARDSRBHegyGMahqO4R0bQcjIQ8E4BMCQc930JluyGRmdAAcdiigMLVrApTYWy5FKM1IQe+Mp+L4rphz+qIOBAUYeCY4p2tGrJZeH9y79mZsawFoaIRxF3JyiYxuHiMGb5KTkpFvZj4ZbYeCiXaOiKBwnxh4fnt9e3ktgZyHhrChinONs3cFAShFF2JhvCZlG5uchYNun5eedRxMAF15XEFRXgZWWdciuM8GCmdSQ84lLQfY5R14wDB5Lyon4ubwS7jx9NcV9/j5+g4JADs=";
            resultado_sp_legajo_por_dni               = tabla_vacia;
            resultado_sp_legajo_por_id_interna        = tabla_vacia;
            resultado_sp_legajo_por_apellido_y_nombre = tabla_vacia;
            resultado_sp_indice_documentos            = tabla_vacia;
            resultado_sp_id_imagenes_sin_asignar      = tabla_vacia;
            resultado_sp_id_imagenes_del_documento    = tabla_vacia;
            resultado_sp_categoria_del_documento      = tabla_vacia;
            resultado_sp_get_imagen                   = tabla_vacia;

            servicioDeLegajos = new ServicioDeDigitalizacionDeLegajos(conexion_mockeada);
        }
예제 #29
0
        [Ignore] //para que ande el teamcity
        public void verifica_que_va_a_la_base_de_alumnos_una_sola_vez()
        {
            Modalidad        modalidad   = TestObjects.ModalidadFinesPuro();
            List <Modalidad> modalidades = new List <Modalidad>();

            modalidades.Add(modalidad);
            Expect.AtLeastOnce.On(TestObjects.RepoModalidadesMockeado()).Method("GetModalidades").WithAnyArguments().Will(Return.Value(modalidades));

            string source = @"      |Id     |Documento   |Apellido     |Nombre     |Telefono      |Mail     |LugarTrabajo |FechaNacimiento         |Direccion  |IdModalidad  |ModalidadDescripcion |IdArea |NombreArea                       |IdOrganismo |DescripcionOrganismo   |IdBaja
                                    |01     |31507315    |Cevey        |Belén      |A111          |belen@ar |MDS          |2012-10-13 21:36:35.077 |Calle      |1            |fines                |0      |Ministerio de Desarrollo Social  |1           |MDS                    |0
                                    |02     |31041236    |Caino        |Fernando   |A222          |fer@ar   |MDS          |2012-10-13 21:36:35.077 |Av         |1            |fines                |1      |Unidad Ministrio                 |1           |MDS                    |0
                                    |05     |31507315    |Cevey        |Belén      |A111          |belen@ar |MDS          |2012-10-13 21:36:35.077 |Calle      |1            |fines                |1      |Unidad Ministrio                 |1           |MDS                    |0
                                    |03     |31507315    |Cevey        |Belén      |A111          |belen@ar |MDS          |2012-10-13 21:36:35.077 |Calle      |1            |fines                |621    |Secretaría de Deportes           |1           |MDS                    |0";

            var mocks       = new Mockery();
            var conexion    = mocks.NewMock <IConexionBD>();
            var repo_alumno = new RepositorioDeAlumnos(conexion, TestObjects.RepoCursosMockeado(), TestObjects.RepoModalidadesMockeado());
            var resultado   = TablaDeDatos.From(source);

            Expect.Once.On(conexion).Method("Ejecutar").WithAnyArguments().Will(Return.Value(resultado));

            repo_alumno.GetAlumnos();
            var alumnos = repo_alumno.GetAlumnos();

            mocks.VerifyAllExpectationsHaveBeenMet();
            Assert.AreEqual(2, alumnos.Count);
        }
예제 #30
0
        public void EnsureValidH2G2IDSucceedsToCreate()
        {
            // Create a mockery of the input context
            Mockery mockery = new Mockery();
            IInputContext mockedContext = mockery.NewMock<IInputContext>();

            IDnaDataReader mockedReader = mockery.NewMock<IDnaDataReader>();
            Stub.On(mockedReader).Method("AddParameter").Will(Return.Value(mockedReader));
            Stub.On(mockedReader).Method("Execute").Will(Return.Value(mockedReader));
            Stub.On(mockedReader).GetProperty("HasRows").Will(Return.Value(true));
            Stub.On(mockedReader).Method("Read").Will(Return.Value(true));
            
            // Set the expiry date to be 1 minute from now
            Stub.On(mockedReader).Method("GetInt32").With("seconds").Will(Return.Value(60));
            Stub.On(mockedReader).Method("Dispose").Will(Return.Value(null));

            Stub.On(mockedContext).Method("CreateDnaDataReader").With("cachegetarticleinfo").Will(Return.Value(mockedReader));

            // Return false for now as it's bloody inpossible to test methods that use ref params!!!
            Stub.On(mockedContext).Method("FileCacheGetItem").Will(Return.Value(false));

            // Now create the setup object and create the guideentry
            GuideEntrySetup setup = new GuideEntrySetup(388217);
            GuideEntry testEntry = new GuideEntry(mockedContext, setup);

            // Test the initialisation code.
            Assert.IsTrue(testEntry.Initialise(), "Valid h2g2id should return true!");
        }
예제 #31
0
        public void GivenRequestToContactFormListPageShouldSetSkipAndShowVariablesInXML()
        {
            Mockery mock = new Mockery();
            IInputContext mockedInputContext = mock.NewMock<IInputContext>();
            ISite mockedSite = mock.NewMock<ISite>();

            Stub.On(mockedSite).GetProperty("SiteID").Will(Return.Value(1));
            Stub.On(mockedInputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));

            IDnaDataReader mockedReader = mock.NewMock<IDnaDataReader>();
            Stub.On(mockedReader).Method("AddParameter");
            Stub.On(mockedReader).Method("Execute");
            Stub.On(mockedReader).GetProperty("HasRows").Will(Return.Value(false));
            Stub.On(mockedReader).Method("Dispose");
            Stub.On(mockedInputContext).Method("CreateDnaDataReader").With("getcontactformslist").Will(Return.Value(mockedReader));

            ContactFormListBuilder contactFormBuilder = new ContactFormListBuilder(mockedInputContext);

            int expectedShow = 200;
            int expectedSkip = 1000;
            int expectedSiteID = 66;

            Stub.On(mockedInputContext).Method("DoesParamExist").With("action", "process action param").Will(Return.Value(false));
            Stub.On(mockedInputContext).Method("DoesParamExist").With("dnaskip", "Items to skip").Will(Return.Value(true));
            Stub.On(mockedInputContext).Method("DoesParamExist").With("dnashow", "Items to show").Will(Return.Value(true));
            Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("dnaskip", "Items to skip").Will(Return.Value(expectedSkip));
            Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("dnashow", "Items to show").Will(Return.Value(expectedShow));
            Stub.On(mockedInputContext).Method("GetParamIntOrZero").With("dnasiteid", "The specified site").Will(Return.Value(expectedSiteID));

            XmlNode requestResponce = contactFormBuilder.GetContactFormsAsXml();

            Assert.AreEqual(expectedShow, Int32.Parse(requestResponce.SelectSingleNode("@SHOW").Value));
            Assert.AreEqual(expectedSkip, Int32.Parse(requestResponce.SelectSingleNode("@SKIP").Value));
            Assert.AreEqual(expectedSiteID, Int32.Parse(requestResponce.SelectSingleNode("@REQUESTEDSITEID").Value));
        }
예제 #32
0
        public void TestRenderFocused()
        {
            Screen.FocusedControl = this.input;
            Screen.InjectKeyPress(Keys.End); // Inject key to make caret visible

            // Make sure the renderer draws at least the input control's text
            MockedGraphics.Expects.AtLeast(0).Method(
                m => m.MeasureString(null, RectangleF.Empty, null)
                ).WithAnyArguments().WillReturn(new RectangleF(0.0f, 0.0f, 200.0f, 10.0f));
            MockedGraphics.Expects.AtLeast(0).Method(
                m => m.SetClipRegion(RectangleF.Empty)
                ).WithAnyArguments();
            MockedGraphics.Expects.AtLeast(0).Method(
                m => m.DrawCaret(null, RectangleF.Empty, null, 0)
                ).WithAnyArguments();

            MockedGraphics.Expects.One.Method(
                m => m.DrawElement(null, RectangleF.Empty)
                ).WithAnyArguments();
            MockedGraphics.Expects.AtLeastOne.Method(
                m => m.DrawString(null, RectangleF.Empty, null)
                ).WithAnyArguments();

            // Let the renderer draw the input control into the mocked graphics interface
            renderer.Render(this.input, MockedGraphics.MockObject);

            // And verify the expected drawing commands were issues
            Mockery.VerifyAllExpectationsHaveBeenMet();
        }
예제 #33
0
        public void TestXmlNoModClass()
        {
            Mockery mocks = new Mockery();
            IInputContext context = mocks.NewMock<IInputContext>();
            IDnaDataReader mockedReader = mocks.NewMock<IDnaDataReader>();
            Stub.On(context).Method("CreateDnaDataReader").Will(Return.Value(mockedReader));
            Stub.On(mockedReader).Method("Execute");
            Stub.On(mockedReader).Method("Dispose");
            IAction mockReaderResults = new MockedReaderResults(new object[] { true, false });
            Stub.On(mockedReader).Method("Read").Will(mockReaderResults);

            // Check Stored Procedure is called as expected.
            Expect.Never.On(mockedReader).Method("AddParameter").With("modclassid");

            Stub.On(mockedReader).Method("GetInt32NullAsZero").With("reasonid").Will(Return.Value(6));
            Stub.On(mockedReader).Method("GetStringNullAsEmpty").With("displayname").Will(Return.Value("DisplayName"));
            Stub.On(mockedReader).Method("GetStringNullAsEmpty").With("emailname").Will(Return.Value("EmailName"));
            Stub.On(mockedReader).Method("GetTinyIntAsInt").With("editorsonly").Will(Return.Value(0));

            ModerationReasons modReasons = new ModerationReasons(context);
            modReasons.GenerateXml(0);

            //Check XML.is as expected.
            XmlNode node = modReasons.RootElement.SelectSingleNode(@"MOD-REASONS");
            Assert.IsNotNull(node, "ModerationReasons Element Found");
            Assert.IsNull(modReasons.RootElement.SelectSingleNode(@"MOD-REASONS/@MODCLASSID"), "Moderation Class Id");
            Assert.IsNotNull(modReasons.RootElement.SelectSingleNode(@"MOD-REASONS/MOD-REASON[@DISPLAYNAME='DisplayName']"), "Displayname");
            Assert.IsNotNull(modReasons.RootElement.SelectSingleNode(@"MOD-REASONS/MOD-REASON[@EMAILNAME='EmailName']"), "Emailname");
            Assert.IsNotNull(modReasons.RootElement.SelectSingleNode(@"MOD-REASONS/MOD-REASON[@EDITORSONLY='0']"), "Editors Only");


            mocks.VerifyAllExpectationsHaveBeenMet();
        }
예제 #34
0
        public void TestGetImportantData_ExceptionHandeling()
        {
            //setup/arrange
            DateTime fromDate = DateTime.Now.Subtract(new TimeSpan(30, 0, 0, 0));
            DateTime toDate = DateTime.Now;
            Request request = new ImportantDataServiceRequestImpl();
            ImportantDataServiceRequest importantRequest = (ImportantDataServiceRequest)request;
            importantRequest.FromDate = fromDate;
            importantRequest.ToDate = toDate;
            DataSet response = new DataSet();
            Mockery mockery = new Mockery();
            Data mockData = mockery.NewMock<Data>();
            Expect.Once.On(mockData).Method("GetImportantDataWithDateRange").With(fromDate, toDate).Will(Throw.Exception(new Exception()));
            ImportantDataService service = new ImportantDataServiceImpl(mockData);

            //execute/act
            try
            {
                service.GetImportantData(request);
                //assert
                Assert.Fail("An Exception should have been thrown");
            }
            catch (ServiceException e)
            {
                Assert.AreEqual("The Service Invocation Failed", e.Message);
            }

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
예제 #35
0
        public void SetUp()
        {
            _mock = new Mockery();
            _site = _mock.NewMock<ISite>();
            Stub.On(_site).GetProperty("DefaultSkin").Will(Return.Value(SITE_DEFAULT_SKIN));
            Stub.On(_site).Method("DoesSkinExist").With(SITE_DEFAULT_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With(INVALID_SKIN).Will(Return.Value(false));
            Stub.On(_site).Method("DoesSkinExist").With(USER_PREFERRED_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With(Is.Null).Will(Return.Value(false));
            Stub.On(_site).Method("DoesSkinExist").With(REQUESTED_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With(FILTER_DERIVED_SKIN).Will(Return.Value(true));
            Stub.On(_site).Method("DoesSkinExist").With("xml").Will(Return.Value(true));
            Stub.On(_site).GetProperty("SkinSet").Will(Return.Value("vanilla"));
            
            _user = _mock.NewMock<IUser>();

            _inputContext = _mock.NewMock<IInputContext>();
            Stub.On(_inputContext).GetProperty("CurrentSite").Will(Return.Value(_site));

            _outputContext = _mock.NewMock<IOutputContext>();
            Stub.On(_outputContext).Method("VerifySkinFileExists").Will(Return.Value(true));
    
            _skinSelector = new SkinSelector();
           
            _request = _mock.NewMock<IRequest>();
        }
예제 #36
0
        public void Should_not_jump_when_sibling_is_zero()
        {
            const int objectNumber = 10;
            const int sibling      = 0;

            var args = new OperandBuilder()
                       .WithArg(objectNumber)
                       .Build();


            var zObj = new ZMachineObjectBuilder()
                       .WithObjectNumber(objectNumber)
                       .WithSibling(sibling)
                       .Build();

            Mockery
            .SetNextObject(zObj);

            Operation.Execute(args);

            Mockery
            .ResultDestinationRetrievedFromPC()
            .ResultStoredWasByte(sibling)
            .JumpedWith(false)
            ;
        }
예제 #37
0
        public void SchedulerRunnerDbStartAndWaitWithDelayBetweenTasksTest()
        {
            InitDb();
            SchedulerConfigurationSection configuration = GetConfiguration(true);

            configuration.SecondsBetweenSchedulerTasks = 60;
            var languages = new List <string> {
                "en", "ru"
            };

            var mocks          = new Mockery();
            var configStrategy = mocks.NewMock <ISchedulerConfigurationStrategy>();

            Expect.Once.On(configStrategy).Method("GetAVRFacade").Will(Return.Value(new AVRFacade(m_Container)));
            Expect.Once.On(configStrategy).Method("GetConfigurationSection").Will(Return.Value(configuration));
            Expect.Once.On(configStrategy).Method("GetLanguages").Will(Return.Value(languages));
            Expect.Once.On(configStrategy).Method("GetServiceDisplayName").Will(Return.Value("service name"));

            Container c = new Container();

            c.Configure(r => { r.For <ISchedulerConfigurationStrategy>().Use(configStrategy); });

            using (var runner = c.GetInstance <SchedulerRunner>())
            {
                runner.Start();
                Thread.Sleep(200);
            }
            mocks.VerifyAllExpectationsHaveBeenMet();
        }
예제 #38
0
        public void OnePlayerNotEnoughRooms()
        {
            var mock      = new Mockery();
            var innOption = mock.NewMock <IInnOption>();

            Stub.On(innOption).GetProperty("MinimumPrice").Will(Return.Value(2));
            Stub.On(innOption).GetProperty("NumberOfBeds").Will(Return.Value(5));
            var player = new MockPlayerForBillet(mock, innOption)
            {
                Money = 10
            };

            player.AddBidResponse(new BidResponse()
            {
                CanRaise = false, MaxBeds = 5, Price = 2
            });

            player.AddWives(Wife.NewWifeList);
            var players = new[] { player };
            var auction = new SynchronousAuction(player.Location.Current, players);
            var result  = auction.Resolve();

            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.Count());
            var bid = result.First();

            Assert.IsNotNull(bid);
            Assert.AreEqual(5, bid.Beds);
            Assert.AreEqual(2, bid.Price);
            Assert.AreEqual(player, bid.Player);
        }
        public void TestPersist()
        {
            Mockery mocks = new Mockery();

            //Crate mocks
            IUserGateway mockGateway = mocks.NewMock<IUserGateway>();
            IUserValidator mockValidator = mocks.NewMock<IUserValidator>();

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

            //Expectations
            using(mocks.Ordered)
            {
                Expect.Once.On(mockValidator).Method("Validate").With(user).Will(Return.Value(true));
                Expect.Once.On(mockGateway).Method("Persist").With(user).Will(Return.Value(true));
            }

            //Assign gateway
            user.Gateway = mockGateway;

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

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
예제 #40
0
        /// <summary>
        /// Constructor for the User Tests to set up the context for the tests
        /// </summary>
        public UserListTests()
        {
            string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
            BBC.Dna.AppContext.OnDnaStartup(rootPath);


            Console.WriteLine("Before RecentSearch - AddRecentSearchTests");

            //Create the mocked _InputContext
            Mockery mock = new Mockery();
            _InputContext = DnaMockery.CreateDatabaseInputContext();

            // Create a mocked site for the context
            ISite mockedSite = DnaMockery.CreateMockedSite(_InputContext, 1, "h2g2", "h2g2", true, "comment");
            Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));
            Stub.On(mockedSite).GetProperty("ModClassID").Will(Return.Value(1));


            BBC.Dna.User user = new BBC.Dna.User(_InputContext);
            Stub.On(_InputContext).GetProperty("ViewingUser").Will(Return.Value(user));
            Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));

            //Create sub editor group and users
            //create test sub editors
            DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2");
            dnaRequest.SetCurrentUserEditor();
            TestDataCreator testData = new TestDataCreator(_InputContext);
            int[] userIDs = new int[10];
            Assert.IsTrue(testData.CreateNewUsers(mockedSite.SiteID, ref userIDs), "Test users not created");
            Assert.IsTrue(testData.CreateNewUserGroup(dnaRequest.CurrentUserID, "subs"), "CreateNewUserGroup not created");
            Assert.IsTrue(testData.AddUsersToGroup(userIDs, mockedSite.SiteID, "subs"), "Unable to add users to group not created");


        }
예제 #41
0
        public void FindElementZeroBy()
        {
            Mockery mock = new Mockery();
            IAllDriver driver = mock.NewMock<IAllDriver>();

            ByChained by = new ByChained();
            by.FindElement(driver);
        }
 public void Setup()
 {
     mocks = new Mockery();
     mockDriver = mocks.NewMock<IWebDriver>();
     mockElement = mocks.NewMock<IWebElement>();
     mockNavigation = mocks.NewMock<INavigation>();
     log = new StringBuilder();
 }
예제 #43
0
        public void FindElementZeroBy()
        {
            Mockery mock = new Mockery();
            IAllDriver driver = mock.NewMock<IAllDriver>();

            ByChained by = new ByChained();
            Assert.Throws<NoSuchElementException>(() => by.FindElement(driver));
        }
 public void SetUp()
 {
     mockery = new Mockery();
     dependencySessionContainer = mockery.NewMock<ISessionContainer>();
     dependencyDb = mockery.NewMock<IWorkTimeAccountingPlatformDAO>();
     dependencySessionIdProvider = mockery.NewMock<ISessionIdProvider>();
     testee = new CommunicationService(dependencySessionContainer, dependencyDb, dependencySessionIdProvider);
 }
 public void beforTest()
 {
     mocks = new Mockery();
     view = mocks.NewMock<IPlaylistSelectorView>();
     task = mocks.NewMock<IPlaylistSelectorTask>();
     lookupList = mocks.NewMock<ILookupList>();
     presenter = new PlaylistSelectorPresenter(view, task);
 }
 public void SetUp()
 {
     m_mockery = new Mockery();
     m_extensionA = m_mockery.NewMock<IMockExtensionTypeA>();
     m_extensionB = m_mockery.NewMock<IMockExtensionTypeB>();
     m_extensionC = new MockExtensionTypeC();
     m_extensionD = m_mockery.NewMock<IMockExtensionTypeD>();
 }
예제 #47
0
 public void Initialize()
 {
     _mockery = new Mockery();
     _view = _mockery.NewMock<IEmployeeView>();
     _service = _mockery.NewMock<IEmployeeService>();
     _model = new EmployeeModel();
     _presenter = new EmployeePresenter(_view, _model, _service);
 }