当前位置: 首页>>代码示例>>C#>>正文


C# Mockery.VerifyAllExpectationsHaveBeenMet方法代码示例

本文整理汇总了C#中Mockery.VerifyAllExpectationsHaveBeenMet方法的典型用法代码示例。如果您正苦于以下问题:C# Mockery.VerifyAllExpectationsHaveBeenMet方法的具体用法?C# Mockery.VerifyAllExpectationsHaveBeenMet怎么用?C# Mockery.VerifyAllExpectationsHaveBeenMet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mockery的用法示例。


在下文中一共展示了Mockery.VerifyAllExpectationsHaveBeenMet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestGetHandlerFor

		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();
		}
开发者ID:divyang4481,项目名称:lextudio,代码行数:27,代码来源:TestHandlerFactory.cs

示例2: ShouldCreateInstanceWithCacheKeyAndInvokeDynamicFactoryTest

        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();
        }
开发者ID:sami1971,项目名称:textmetal,代码行数:28,代码来源:ProxyFactoryTests.cs

示例3: TestPersist

        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();
        }
开发者ID:pweibel,项目名称:DotNetMockingFrameworksDemo,代码行数:26,代码来源:NMock2Test.cs

示例4: TestXmlForModClass

        public void TestXmlForModClass()
        {
            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.Once.On(mockedReader).Method("AddParameter").With("modclassid", 1);

            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(1);

            //Check XML.is as expected.
            XmlNode node = modReasons.RootElement.SelectSingleNode(@"MOD-REASONS");
            Assert.IsNotNull(node, "ModerationReasons Element Found");
            Assert.IsNotNull(modReasons.RootElement.SelectSingleNode(@"MOD-REASONS[@MODCLASSID='1']"), "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();
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:33,代码来源:ModerationReasonsTests.cs

示例5: TestAppstoreShopListParseMechanics

        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);
        }
开发者ID:QuiVeeGlobal,项目名称:sdk-unity,代码行数:35,代码来源:XmlToAppstoreText.cs

示例6: TestGetImportantData_ExceptionHandeling

        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();
        }
开发者ID:rdammkoehler,项目名称:C-TDDExamples,代码行数:29,代码来源:TestService.cs

示例7: TestTasksListParseMechanics

        public void TestTasksListParseMechanics()
        {
            string xml =
            @"<roar tick=""135577684654"">
                <tasks>
                    <list status=""ok"">
                        <task ikey=""dungeon_crawl"">
                            <label>Dungeon crawl</label>
                            <description>Go into the pits</description>
                            <location>Australia</location>
                            <tags>
                                <tag value=""protect""/>
                                <tag value=""monsters""/>
                            </tags>
                            <costs>
                                <item_cost ikey=""mariner"" number_required=""3"" ok=""false"" reason=""requires mariner(3)""/>
                                <stat_cost type=""currency"" ikey=""premium_currency"" value=""477"" ok=""true""/>
                            </costs>
                            <rewards>
                                <grant_stat type=""currency"" ikey=""premium_currency"" value=""453""/>
                                <grant_xp value=""234""/>
                            </rewards>
                            <mastery level=""2"" progress=""5""/>
                            <requires>
                                <item_requirement ikey=""talisman"" number_required=""2"" ok=""false"" reason=""requires talisman(2)""/>
                            </requires>
                        </task>
                    </list>
                </tasks>
            </roar>";

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Mockery mockery = new Mockery();
            Roar.DataConversion.IXCRMParser ixcrm_parser = mockery.NewMock<Roar.DataConversion.IXCRMParser>();
            Roar.DataConversion.Responses.Tasks.List list_parser = new Roar.DataConversion.Responses.Tasks.List();
            list_parser.ixcrm_parser = ixcrm_parser;
            Roar.DomainObjects.Task task_data = new Roar.DomainObjects.Task();

            Expect.Once.On(ixcrm_parser).Method("ParseCostList").With(nn.SelectSingleNode("./tasks/list/task/costs")).Will(Return.Value(task_data.costs));
            Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(nn.SelectSingleNode("./tasks/list/task/rewards")).Will(Return.Value(task_data.rewards));
            Expect.Once.On(ixcrm_parser).Method("ParseRequirementList").With(nn.SelectSingleNode("./tasks/list/task/requires")).Will(Return.Value(task_data.requirements));
            Expect.Once.On(ixcrm_parser).Method("ParseTagList").With(nn.SelectSingleNode("./tasks/list/task/tags")).Will(Return.Value(task_data.tags));

            ListResponse response = list_parser.Build(nn);

            mockery.VerifyAllExpectationsHaveBeenMet();

            Assert.AreEqual(response.tasks.Count, 1);
            Assert.AreEqual(response.tasks[0].costs.Count, 0);
            Assert.AreEqual(response.tasks[0].rewards.Count, 0);
            Assert.AreEqual(response.tasks[0].requirements.Count, 0);
            Assert.AreEqual(response.tasks[0].tags.Count, 0);
            Assert.AreEqual(response.tasks[0].costs, task_data.costs);
            Assert.AreEqual(response.tasks[0].rewards, task_data.rewards);
            Assert.AreEqual(response.tasks[0].requirements, task_data.requirements);
            Assert.AreEqual(response.tasks[0].tags, task_data.tags);
        }
开发者ID:QuiVeeGlobal,项目名称:sdk-unity,代码行数:57,代码来源:XmlToTasksTest.cs

示例8: FindElementsOneBy

        public void FindElementsOneBy()
        {
            Mockery mock = new Mockery();
            IAllDriver driver = mock.NewMock<IAllDriver>();
            IAllElement elem1 = mock.NewMock<IAllElement>();
            IAllElement elem2 = mock.NewMock<IAllElement>();
            var elems12 = new List<IWebElement>() { elem1, elem2 }.AsReadOnly();
            Expect.Once.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));

            ByChained by = new ByChained(By.Name("cheese"));
            Assert.AreEqual(by.FindElements(driver), elems12);
            mock.VerifyAllExpectationsHaveBeenMet();
        }
开发者ID:kaushik9k,项目名称:Selenium2,代码行数:13,代码来源:ByChainedTests.cs

示例9: TestLoadCommand

        public void TestLoadCommand()
        {
            Mockery mockery = new Mockery();
            IProjectSerializer serializer = mockery.NewMock<IProjectSerializer>();
            RuleCommand rc = new RuleCommand();

            Expect.Once.On(serializer).GetProperty("LineNumber").Will(Return.Value(1));
            Expect.Once.On(serializer).Method("ReadTextToken").Will(Return.Value(new Token(TokenType.Text, "a", 0, 1)));
            Expect.Once.On(serializer).Method("ReadTextToken").Will(Return.Value(null));

            rc.LoadCommand(serializer);

            Assert.AreEqual("a", rc.Rule);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
开发者ID:alfar,项目名称:WordBuilder,代码行数:16,代码来源:RuleCommandTest.cs

示例10: FindElementOneByEmpty

        public void FindElementOneByEmpty()
        {
            var mock = new Mockery();
            var driver = mock.NewMock<IAllDriver>();
            var empty = new List<IWebElement>().AsReadOnly();

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

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

            // one element
            Assert.Throws<NoSuchElementException>(() => by.FindElement(driver));
            Assert.That(by.FindElements(driver), Is.EqualTo(empty));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
开发者ID:RanchoLi,项目名称:selenium,代码行数:16,代码来源:ByAllTests.cs

示例11: ShouldAddResolution1Test

        public void ShouldAddResolution1Test()
        {
            DependencyManager dependencyManager;
            Mockery mockery;
            IDependencyResolution mockDependencyResolution;
            string selectorKey;

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

            dependencyManager = new DependencyManager();
            selectorKey = "x";

            dependencyManager.AddResolution<object>(selectorKey, mockDependencyResolution);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
开发者ID:sami1971,项目名称:textmetal,代码行数:17,代码来源:DependencyManagerTests.cs

示例12: FindElementOneBy

        public void FindElementOneBy()
        {
            var mock = new Mockery();
            var driver = mock.NewMock<IAllDriver>();
            var elem1 = mock.NewMock<IAllElement>();
            var elem2 = mock.NewMock<IAllElement>();
            var elems12 = new List<IWebElement> { elem1, elem2 }.AsReadOnly();
            Expect.AtLeastOnce.On(driver).Method("FindElementsByName").With("cheese").Will(Return.Value(elems12));
            var by = new ByAll(By.Name("cheese"));

            // findElement
            Assert.AreEqual(by.FindElement(driver), elem1);
            //findElements
            Assert.That(by.FindElements(driver), Is.EqualTo(elems12));

            mock.VerifyAllExpectationsHaveBeenMet();
        }
开发者ID:RanchoLi,项目名称:selenium,代码行数:17,代码来源:ByAllTests.cs

示例13: Test_CreateEmptyPolicyWithDefaultUserSucceeds_WithFixture

        public void Test_CreateEmptyPolicyWithDefaultUserSucceeds_WithFixture()
        {
            //setup/arrange
            Mockery mockery = new Mockery();
            User user = new UserFixture().CreateValidUser();
            PolicyDAO policyDAO = mockery.NewMock<PolicyDAO>();
            Expect.Once.On(policyDAO).Method("Save").WithAnyArguments();
            PolicyManager manager = new PolicyManagerImpl(policyDAO);

            //execute/act
            Policy policy = manager.CreateEmptyPolicy(user);

            //assert
            mockery.VerifyAllExpectationsHaveBeenMet();
            Assert.AreSame(user, policy.Holder, "holder should be user we created for");
            Assert.AreEqual(0, policy.Coverages.Count, "coverages should be zero");
        }
开发者ID:rdammkoehler,项目名称:C-TDDExamples,代码行数:17,代码来源:CreatePolicyTests.cs

示例14: ShouldExecuteReaderCloseConnectionSprocWithParametersTest

        public void ShouldExecuteReaderCloseConnectionSprocWithParametersTest()
        {
            Mockery mockery;
            IDbConnection mockDbConnection;
            IDbCommand mockDbCommand;
            IDataParameterCollection mockDataParameterCollection;
            IDataParameter[] mockDataParameters;
            IDataParameter mockDataParameter0;
            IDataParameter mockDataParameter1;
            IDataReader mockDataReader;

            IDataReader dataReader;

            mockery = new Mockery();
            mockDbConnection = mockery.NewMock<IDbConnection>();
            mockDbCommand = mockery.NewMock<IDbCommand>();
            mockDataParameterCollection = mockery.NewMock<IDataParameterCollection>();
            mockDataParameter0 = mockery.NewMock<IDataParameter>();
            mockDataParameter1 = mockery.NewMock<IDataParameter>();
            mockDataParameters = new IDataParameter[] { mockDataParameter0, mockDataParameter1 };
            mockDataReader = mockery.NewMock<IDataReader>();

            Expect.AtLeastOnce.On(mockDbConnection).Method("CreateCommand").WithNoArguments().Will(Return.Value(mockDbCommand));
            Expect.AtLeastOnce.On(mockDbCommand).GetProperty("Parameters").Will(Return.Value(mockDataParameterCollection));
            Expect.AtLeastOnce.On(mockDataParameterCollection).Method("Clear").WithNoArguments();
            Expect.AtLeastOnce.On(mockDbCommand).Method("Dispose").WithNoArguments();
            Expect.AtLeastOnce.On(mockDbCommand).SetProperty("Connection").To(mockDbConnection);
            Expect.AtLeastOnce.On(mockDbCommand).SetProperty("CommandType").To(CommandType.StoredProcedure);
            Expect.AtLeastOnce.On(mockDbCommand).SetProperty("CommandText").To("blah blah blah");
            Expect.AtLeastOnce.On(mockDbCommand).SetProperty("Transaction");
            Expect.AtLeastOnce.On(mockDbCommand).Method("ExecuteReader").With(CommandBehavior.CloseConnection).Will(Return.Value(mockDataReader));
            Expect.AtLeastOnce.On(mockDataParameter0).GetProperty("Value").Will(Return.Value(1));
            Expect.AtLeastOnce.On(mockDataParameter1).GetProperty("Value").Will(Return.Value(null));
            Expect.AtLeastOnce.On(mockDataParameter1).SetProperty("Value").To(DBNull.Value);
            Expect.AtLeastOnce.On(mockDataParameterCollection).Method("Add").With(mockDataParameter0).Will(Return.Value(0));
            Expect.AtLeastOnce.On(mockDataParameterCollection).Method("Add").With(mockDataParameter1).Will(Return.Value(0));
            Expect.AtLeastOnce.On(mockDataReader).Method("Dispose").WithNoArguments();

            dataReader = AdoNetHelper.ExecuteReader(mockDbConnection, null, CommandType.StoredProcedure, "blah blah blah", mockDataParameters, CommandBehavior.CloseConnection, null, false);

            Assert.IsNotNull(dataReader);

            dataReader.Dispose();

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
开发者ID:sami1971,项目名称:textmetal,代码行数:46,代码来源:AdoNetHelperTests.cs

示例15: TestChromeWebStoreListParseMechanics

        public void TestChromeWebStoreListParseMechanics()
        {
            string xml =
            @"<roar tick=""130695522924"">
                <chrome_web_store>
                    <list>
                        <shopitem blah=""???"" ikey=""token"" label=""Token"" description=""Chrome Token"" price=""23"" jwt=""????"">
                            <modifiers>
                                <grant_item ikey=""item_ikey_1""/>
                            </modifiers>
                            <tags>
                                <tag value=""a_tag""/>
                                <tag value=""another_tag""/>
                            </tags>
                        </shopitem>
                    </list>
                </chrome_web_store>
            </roar>";

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.ChromeWebStore.List list_parser = new Roar.DataConversion.Responses.ChromeWebStore.List();

            Mockery mockery = new Mockery();
            Roar.DataConversion.IXCRMParser ixcrm_parser = mockery.NewMock<Roar.DataConversion.IXCRMParser>();
            list_parser.ixcrm_parser = ixcrm_parser;
            IList<Roar.DomainObjects.Modifier> modifier_list = new List<Roar.DomainObjects.Modifier>();
            IList<string> tag_list = new List<string>();

            Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(nn.SelectSingleNode("./chrome_web_store/list/shopitem/modifiers")).Will(Return.Value(modifier_list));
            Expect.Once.On(ixcrm_parser).Method("ParseTagList").With(nn.SelectSingleNode("./chrome_web_store/list/shopitem/tags")).Will(Return.Value(tag_list));

            ListResponse response = list_parser.Build(nn);

            mockery.VerifyAllExpectationsHaveBeenMet();

            Assert.IsNotNull(response.shop_items);
            Assert.AreEqual(response.shop_items.Count, 1);
            Assert.AreEqual(response.shop_items[0].ikey, "token");
            Assert.AreEqual(response.shop_items[0].label, "Token");
            Assert.AreEqual(response.shop_items[0].description, "Chrome Token");
            Assert.AreEqual(response.shop_items[0].price, "23");
            Assert.AreEqual(response.shop_items[0].jwt, "????");
            Assert.AreEqual(response.shop_items[0].modifiers, modifier_list);
            Assert.AreEqual(response.shop_items[0].tags, tag_list);
        }
开发者ID:QuiVeeGlobal,项目名称:sdk-unity,代码行数:45,代码来源:XmlToChromeWebStoreTest.cs


注:本文中的Mockery.VerifyAllExpectationsHaveBeenMet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。