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


C# Mock.VerifyGet方法代码示例

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


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

示例1: TestAddingRecordingDeviceToSelected

        public void TestAddingRecordingDeviceToSelected()
        {
            var configurationMoq = new Mock<ISoundSwitchConfiguration> {Name = "Configuration mock"};
            var audioMoqI = new Mock<IAudioDevice> {Name = "first audio dev"};
            audioMoqI.SetupGet(a => a.FriendlyName).Returns("Speakers (Test device)");
            audioMoqI.SetupGet(a => a.Type).Returns(AudioDeviceType.Recording);

            //Setup
            configurationMoq.Setup(c => c.SelectedRecordingDeviceList).Returns(new HashSet<string>());
            TestHelpers.SetConfigurationMoq(configurationMoq);

            //Action
            var eventCalled = false;
            AppModel.Instance.SelectedDeviceChanged += (sender, changed) => eventCalled = true;
            Assert.True(AppModel.Instance.SelectDevice(audioMoqI.Object));

            //Asserts
            configurationMoq.VerifyGet(c => c.SelectedRecordingDeviceList);
            configurationMoq.Verify(c => c.Save());
            audioMoqI.VerifyGet(a => a.FriendlyName);
            audioMoqI.VerifyGet(a => a.Type);
            Assert.That(configurationMoq.Object.SelectedRecordingDeviceList.Count == 1);
            Assert.That(configurationMoq.Object.SelectedRecordingDeviceList.Contains("Speakers (Test device)"));
            Assert.That(eventCalled, "SelectedDeviceChanged not called");
        }
开发者ID:BellCJT,项目名称:SoundSwitch,代码行数:25,代码来源:RecordingDevices.cs

示例2: When_all_Rovers_deployed_requests_Rover_Positions_and_CardinalDirections

            public void When_all_Rovers_deployed_requests_Rover_Positions_and_CardinalDirections()
            {
                var mockRover = new Mock<IRover>();
                mockRover.Setup(x => x.IsDeployed()).Returns(true);
                var rovers = new List<IRover> {mockRover.Object, mockRover.Object, mockRover.Object};

                var reportComposer = new ConsoleReportComposer();
                reportComposer.CompileReports(rovers);

                mockRover.VerifyGet(x => x.Position, Times.Exactly(3));
                mockRover.VerifyGet(x => x.CardinalDirection, Times.Exactly(3));
            }
开发者ID:emretiryaki,项目名称:MarsRover,代码行数:12,代码来源:ConsoleReportComposerTests.cs

示例3: AucunRafraichissementNestFaitSiLaValeurEstVide

        public void AucunRafraichissementNestFaitSiLaValeurEstVide()
        {
            FiltrePresenter presenter = new FiltrePresenter(Vue, Repository.Object);
            Mock<IFiltreView> mock = new Mock<IFiltreView>();
            mock.SetupGet(vue => vue.BlockAffichageFiltres).Verifiable();
            mock.SetupGet(vue => vue.ListeBoxVille).Verifiable();

            presenter.ActualiseLaListeDeFiltre(string.Empty, mock.Object.ListeBoxVille);

            //On passe une fois par le get de la listBox lors du passage de paramètre
            mock.VerifyGet(vue => vue.ListeBoxVille, Times.Exactly(1));
            mock.VerifyGet(vue => vue.BlockAffichageFiltres, Times.Never());
        }
开发者ID:QTruffart,项目名称:Jobs,代码行数:13,代码来源:FiltrePresenterTests.cs

示例4: CustomerCreateCommand

        public void CreateAssignedWorkStation_ValidCommand_Verify_WorkStationId_Get_From_ApplicationSettings_Using_Setup_Property()
        {
            //Arrange
            var createCommmand = new CustomerCreateCommand()
            {
                FirstName = "Mohamed",
                LastName = "Ahmed"
            };

            var mockCustomerRepository = new Mock<ICustomerRepository>();
            var mockApplicationSettings = new Mock<IApplicationSettings>();

            mockCustomerRepository.Setup(x => x.Save(It.IsAny<Customer>()));
            //mockApplicationSettings.Setup(x => x.WorkStationId)
            //    .Returns(10);

            mockApplicationSettings.SetupProperty(x => x.WorkStationId, 123);

            //Can we set if from the object itself??
            //mockApplicationSettings.Object.WorkStationId = 345;

            //mockApplicationSettings.SetupAllProperties();

            CustomerService_8 customerService = new CustomerService_8(
                mockCustomerRepository.Object,
                mockApplicationSettings.Object
                );

            //Act
            customerService.CreateAssignedWorkStation(createCommmand);

            //Assert
            mockApplicationSettings.VerifyGet(x => x.WorkStationId);
        }
开发者ID:mkhodary,项目名称:Mocking_Samples_With_Moq,代码行数:34,代码来源:8_Properties.Test.cs

示例5: CreateAssignedWorkStation_ValidCommand_Verify_WorkStationId_Get_From_ApplicationSettings

        public void CreateAssignedWorkStation_ValidCommand_Verify_WorkStationId_Get_From_ApplicationSettings()
        {
            //Arrange
            var createCommmand = new CustomerCreateCommand()
            {
                FirstName = "Mohamed",
                LastName = "Ahmed"
            };

            var mockCustomerRepository = new Mock<ICustomerRepository>();
            var mockApplicationSettings = new Mock<IApplicationSettings>();

            mockCustomerRepository.Setup(x => x.Save(It.IsAny<Customer>()));
            mockApplicationSettings.Setup(x => x.WorkStationId)
                .Returns(10);

            CustomerService_8 customerService = new CustomerService_8(
                mockCustomerRepository.Object,
                mockApplicationSettings.Object
                );

            //Act
            customerService.CreateAssignedWorkStation(createCommmand);

            //Assert
            mockApplicationSettings.VerifyGet(x => x.WorkStationId);
        }
开发者ID:mkhodary,项目名称:Mocking_Samples_With_Moq,代码行数:27,代码来源:8_Properties.Test.cs

示例6: Example

        private void Example()
        {
            var mock = new Mock<IFoo>();

            mock.Verify(foo => foo.Execute("ping"));

            // Verify with custom error message for failure
            mock.Verify(foo => foo.Execute("ping"), "When doing operation X, the service should be pinged always");

            // Method should never be called
            mock.Verify(foo => foo.Execute("ping"), Times.Never());

            // Called at least once
            mock.Verify(foo => foo.Execute("ping"), Times.AtLeastOnce());

            mock.VerifyGet(foo => foo.Name);

            // Verify setter invocation, regardless of value.
            mock.VerifySet(foo => foo.Name);

            // Verify setter called with specific value
            mock.VerifySet(foo => foo.Name = "foo");

            // Verify setter with an argument matcher
            mock.VerifySet(foo => foo.Value = It.IsInRange(1, 5, Range.Inclusive));
        }
开发者ID:taeatonDev,项目名称:UnitTestTraining,代码行数:26,代码来源:MOQ_Verification.cs

示例7: EqualityCheckAspect_Can_Be_Applied_To_ValueType

 public void EqualityCheckAspect_Can_Be_Applied_To_ValueType()
 {
     var mock = new Mock<MockEqualityChecked> {CallBase = true};
     var underTest = mock.Object;
     underTest.Flag = true;
     underTest.Flag = true;
     mock.VerifyGet(x=>x.Flag, Times.AtLeast(2));
     mock.Verify(x=>x.SetFlag(It.IsAny<bool>()), Times.Once());
 }
开发者ID:DamianReeves,项目名称:PostEdge,代码行数:9,代码来源:GuardPropertyEqualityAspectTests.cs

示例8: WrapsDatabase

        public void WrapsDatabase()
        {
            var mockConn = new Mock<IAdomdConnection>();
            mockConn.SetupGet(p => p.Database).Returns("TEST");

            var conn = new GlimpseAdomdConnection(mockConn.Object, new Mock<ITimedMessagePublisher>().Object);
            Assert.That(conn.Database, Is.EqualTo("TEST"));
            mockConn.VerifyGet(p => p.Database, Times.Once);
        }
开发者ID:ogaudefroy,项目名称:Glimpse.Adomd,代码行数:9,代码来源:GlimpseAdomdConnectionTest.cs

示例9: WatchedDirectoryConfigureWhenStrategyNotDefinedPullsValuesFromWatchDirectoryProperly

        public void WatchedDirectoryConfigureWhenStrategyNotDefinedPullsValuesFromWatchDirectoryProperly()
        {
            // Arrange
            var testBundle = new WatchedDirectoryTestBundle();
            var mockWatchDirectory = new Mock<IWatchDirectory>();

            mockWatchDirectory.SetupGet(x => x.FileExtensions).Returns("abc");

            // Act
            testBundle.WatchedDirectory.Configure(mockWatchDirectory.Object);

            // Assert
            mockWatchDirectory.VerifyGet(x => x.Path, Times.Once());
            mockWatchDirectory.VerifyGet(x => x.IncludeSubDirectories, Times.Once());
            mockWatchDirectory.VerifyGet(x => x.Mode, Times.Once());
            mockWatchDirectory.VerifyGet(x => x.SortStrategy, Times.Once());
            mockWatchDirectory.VerifyGet(x => x.FileExtensions, Times.Once());
        }
开发者ID:MadDonkeySoftware,项目名称:DonkeySuite,代码行数:18,代码来源:WatchedDirectoryTest.cs

示例10: WrapsConnectionTimeout

        public void WrapsConnectionTimeout()
        {
            var mockConn = new Mock<IAdomdConnection>();
            mockConn.SetupGet(p => p.ConnectionTimeout).Returns(30);

            var conn = new GlimpseAdomdConnection(mockConn.Object, new Mock<ITimedMessagePublisher>().Object);
            Assert.That(conn.ConnectionTimeout, Is.EqualTo(30));
            mockConn.VerifyGet(p => p.ConnectionTimeout, Times.Once);
        }
开发者ID:ogaudefroy,项目名称:Glimpse.Adomd,代码行数:9,代码来源:GlimpseAdomdConnectionTest.cs

示例11: Integration

		public void Integration()
		{
			var discountMock = new Mock<IOrderDiscount>();
			discountMock.SetupGet(m => m.MemberGroups).Returns(new List<string>());
			discountMock.SetupGet(m => m.AffectedOrderlines).Returns(new List<int>());

			_discountCalculationService.DiscountAmountForOrder(discountMock.Object, _order);

			discountMock.VerifyGet(m => m.AffectedProductTags);
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:10,代码来源:AffectedTagsTests.cs

示例12: filereader_is_transparent

        public void filereader_is_transparent()
        {
            var settings = new Mock<ISettingsReader>();
            settings.SetupGet(m => m["hue"]).Verifiable();

            var filereader = new FileReader(@"data\FileSettingsReaderTestData", settings.Object);

            filereader.EnsureKey("hue", "9");
            var crap = filereader["hue"];
            var stuff = filereader.Keys;
            filereader.Settings = "new settings";
            crap = filereader.Settings;

            settings.Verify(m => m.EnsureKey("hue", "9"), Times.AtLeastOnce());

            settings.VerifyGet(m => m.Keys, Times.AtLeastOnce());
            settings.VerifyGet(m => m.Settings, Times.AtLeastOnce());
            settings.VerifySet(m => { m.Settings = "new settings"; }, Times.AtLeastOnce());
            settings.Verify();
        }
开发者ID:Krizzzn,项目名称:shutupify,代码行数:20,代码来源:FileReaderTest.cs

示例13: CallingColumnReturnsDeleteColumnExpressionBuilder

        public void CallingColumnReturnsDeleteColumnExpressionBuilder()
        {
            var collectionMock = new Mock<ICollection<IMigrationExpression>>();
            var contextMock = new Mock<IMigrationContext>();
            contextMock.Setup(x => x.Expressions).Returns(collectionMock.Object);

            var root = new DeleteExpressionRoot(contextMock.Object);
            var builder = root.Column("Bacon");

            builder.ShouldBeOfType<DeleteColumnExpressionBuilder>();
            contextMock.VerifyGet(x => x.Expressions);
        }
开发者ID:xalzan,项目名称:fluentmigrator,代码行数:12,代码来源:DeleteExpressionRootTests.cs

示例14: WrapsConnectionString

        public void WrapsConnectionString()
        {
            var mockConn = new Mock<IAdomdConnection>();
            mockConn.SetupProperty(p => p.ConnectionString, "TEST");

            var conn = new GlimpseAdomdConnection(mockConn.Object, new Mock<ITimedMessagePublisher>().Object);
            Assert.That(conn.ConnectionString, Is.EqualTo("TEST"));
            mockConn.VerifyGet(p => p.ConnectionString, Times.Once);
            conn.ConnectionString = "ABC";
            Assert.That(conn.ConnectionString, Is.EqualTo("ABC"));
            mockConn.VerifySet(p => p.ConnectionString = It.Is<string>(s => s == "ABC"), Times.Once);
        }
开发者ID:ogaudefroy,项目名称:Glimpse.Adomd,代码行数:12,代码来源:GlimpseAdomdConnectionTest.cs

示例15: CallingTableReturnsRenameTableExpressionBuilder

        public void CallingTableReturnsRenameTableExpressionBuilder()
        {
            var collectionMock = new Mock<ICollection<IMigrationExpression>>();
            var contextMock = new Mock<IMigrationContext>();
            contextMock.SetupGet(x => x.Expressions).Returns(collectionMock.Object);

            var root = new RenameExpressionRoot(contextMock.Object);
            var builder = root.Table("Bacon");

            builder.ShouldBeOfType<RenameTableExpressionBuilder>();
            contextMock.VerifyGet(x => x.Expressions);
        }
开发者ID:BarsBarsovich,项目名称:fluentmigrator,代码行数:12,代码来源:RenameExpressionRootTests.cs


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