本文整理汇总了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");
}
示例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));
}
示例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());
}
示例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);
}
示例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);
}
示例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));
}
示例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());
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}