本文整理汇总了C#中IFixture类的典型用法代码示例。如果您正苦于以下问题:C# IFixture类的具体用法?C# IFixture怎么用?C# IFixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFixture类属于命名空间,在下文中一共展示了IFixture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: For_ReturnsCombinationOfDepthAndMemberTypesStrings
public void For_ReturnsCombinationOfDepthAndMemberTypesStrings(
[Frozen] IGetDepthString getDepthString,
[Frozen] IGetMemberTypesString getMemberTypesString,
DefaultGetNodeString sut,
string depthString,
string memberTypesString,
int depth,
IFixture fixture)
{
// Arrange
fixture.MakeNonRecursive();
var graphNode = fixture.Create<GraphNode>();
getDepthString.For(depth).Returns(depthString);
getMemberTypesString.For(graphNode).Returns(memberTypesString);
var expectedResult = depthString + memberTypesString;
// Act
var result = sut.For(graphNode, depth);
// Assert
Assert.Equal(expectedResult, result);
}
示例2: Customize
public void Customize(IFixture fixture)
{
var contextFixture = new StructureMapFixture();
fixture.Register(() => contextFixture);
fixture.Customizations.Add(new ContainerBuilder(contextFixture.Container));
}
示例3: CreateTests
public override IEnumerable<ITestCase> CreateTests(
IFixture fixture,
MethodInfo method
)
{
yield return new MethodTestCase(fixture.Name, method);
}
示例4: ViewContext
private static void ViewContext(IFixture fixture)
{
fixture.Register<ControllerBase, ViewContext>(
controllerBase =>
new ViewContext
{TempData = new TempDataDictionary(), ViewData = new ViewDataDictionary(), Controller = controllerBase});
}
示例5: Customize
public void Customize(IFixture fixture)
{
fixture.Customize<Mock<MethodInfo>>(c => c
.Do(stub => stub
.SetupGet(m => m.ReflectedType.Name)
.Returns(fixture.CreateAnonymous<string>())));
}
示例6: Customize
public void Customize(IFixture fixture)
{
ControllerDescriptor(fixture);
ActionDescriptor(fixture);
ActionExecutedContext(fixture);
ActionExecutingContext(fixture);
ViewEngineResult(fixture);
ViewContext(fixture);
ControllerBase(fixture);
IValueProvider(fixture);
ModelBindingContext(fixture);
ValueProviderResult(fixture);
fixture.Customize<ControllerContext>(cc => cc.Without(c => c.DisplayMode));
fixture.Customize<ExceptionContext>(ec => ec.Without(c => c.DisplayMode));
fixture.Customize<ResultExecutedContext>(rec => rec.Without(c => c.DisplayMode));
fixture.Customize<AuthorizationContext>(ac => ac.Without(c => c.DisplayMode));
fixture.Customize<ResultExecutingContext>(rec => rec.Without(c => c.DisplayMode));
fixture.Register<HttpContextBase>(
() =>
{
var mock = new Mock<HttpContextBase>();
mock.Setup(m => m.Items).Returns(new Dictionary<string, object>());
return mock.Object;
});
}
示例7: Customize
public void Customize(IFixture fixture)
{
fixture.Customize<JournaledEvent>(composer => composer
.FromFactory(() => JournaledEvent.Create(
new object(),
(_, type, writer) => writer.WriteLine(fixture.Create("EventPayload")))));
}
示例8:
void ICustomization.Customize(IFixture fixture)
{
this.Customize(fixture);
fixture.Register(() =>
{
var fileSystem = new Mock<IFileSystem>();
fileSystem.SetupGet(f => f.PackagesFile).Returns("scriptcs_packages.config");
fileSystem.SetupGet(f => f.PackagesFolder).Returns("scriptcs_packages");
fileSystem.SetupGet(f => f.BinFolder).Returns("scriptcs_bin");
fileSystem.SetupGet(f => f.DllCacheFolder).Returns(".scriptcs_cache");
fileSystem.SetupGet(f => f.NugetFile).Returns("scriptcs_nuget.config");
fileSystem.SetupGet(f => f.CurrentDirectory).Returns("workingdirectory");
fileSystem.Setup(f => f.FileExists(@"workingdirectory\scriptcs_packages\PackageScripts.csx")).Returns(false);
fileSystem.Setup(f => f.DirectoryExists(@"workingdirectory\scriptcs_packages")).Returns(true);
fileSystem.Setup(f => f.GetWorkingDirectory(It.IsAny<string>())).Returns("workingdirectory");
return fileSystem;
});
fixture.Register(() =>
{
var composer = new Mock<IScriptLibraryComposer>();
composer.SetupGet(c => c.ScriptLibrariesFile).Returns("ScriptLibraries.csx");
return composer;
});
}
示例9: Customize
public void Customize(IFixture fixture)
{
fixture.Register<IContactFactory>(
() =>
{
var factory = new Mock<IContactFactory>();
factory.Setup(f => f.Create(It.IsAny<ID>()))
.Returns(
(ID id) =>
{
// get facet map
var contactFacetMap = new Dictionary<string, Type>()
{
{"Personal", typeof(IContactPersonalInfo)},
{"Addresses", typeof(IContactAddresses)},
{"Emails", typeof(IContactEmailAddresses)},
{"Phone Numbers", typeof(IContactPhoneNumbers)},
{"Picture", typeof(IContactPicture)}
};
//{"Communication Profile", typeof(IContactCoummunicationProfile)},
//{"Preferences", typeof(IContactPreferences)},
//{"SocialProfile", typeof(Sitecore.Social.Connector.Facets.Contact.SocialProfile.ISocialProfileFacet)}
var result = ModelFactory.CreateContact(id, contactFacetMap);
return result;
});
return factory.Object;
});
}
示例10: ViewModel_ShouldReturnCorrectValue
public async Task ViewModel_ShouldReturnCorrectValue(
IFixture fixture,
TestSchedulers scheduler)
{
//arrange
const int insertionIndex = 5;
var initialList = fixture.CreateMany<int>(10).ToArray();
var addedList = fixture.CreateMany<int>(10).ToArray();
var expected = initialList.Take(insertionIndex)
.Concat(addedList.Reverse())
.Concat(initialList.Skip(insertionIndex))
.ToArray();
var notifications = scheduler.CreateColdObservable(addedList.Select((i, ii) => OnNext(Subscribed + 1 + ii, i)).ToArray());
var sut = new UpdatableObservableViewModelBuilderOptions<int, int[], int>(
_ => { },
ct => Task.FromResult(initialList),
() => notifications,
scheduler,
scheduler,
scheduler)
.UpdateAction((i, o) => () => o.Insert(insertionIndex, i))
.ToViewModel();
//act
scheduler.Start();
await sut.RefreshAsync();
scheduler.AdvanceBy(Disposed);
var actual = ((IObservableViewModel<ObservableCollection<int>>)sut).CurrentValue;
//assert
actual.ShouldAllBeEquivalentTo(expected);
}
示例11: Customize
/// <summary>Customizes an <see cref="IFixture"/> to enable auto-mocking with NSubstitute.</summary>
/// <param name="fixture">The fixture upon which to enable auto-mocking.</param>
public void Customize(IFixture fixture)
{
if (fixture == null)
throw new ArgumentNullException("fixture");
fixture.ResidueCollectors.Add(Builder);
}
示例12: ViewModel_WhenRefreshed_ShouldDisposePreviousNotificationsSubscriptions
public async Task ViewModel_WhenRefreshed_ShouldDisposePreviousNotificationsSubscriptions(
IFixture fixture,
TestSchedulers scheduler,
int[] values)
{
//arrange
var notifications = scheduler.CreateColdObservable<int>();
var sut = new UpdatableObservableViewModelBuilderOptions<int, int[], int>(
_ => { },
ct => Task.FromResult(values),
() => notifications,
scheduler,
scheduler,
scheduler)
.UpdateAction((i, o) => () => { })
.ToViewModel();
const long disposeTime = 805;
//act
scheduler.Start();
await sut.RefreshAsync();
//we advance to an arbitrary time
scheduler.AdvanceBy(disposeTime);
//the subscription to the new observable should happen here
//the first subscription should be dispose at the current scheduler time
await sut.RefreshAsync();
//assert
notifications.Subscriptions[0].Unsubscribe.Should().Be(disposeTime);
}
示例13: AddFixture
private void AddFixture(TestAssembly testAssembly, IFixture fixture)
{
List<ITestCase> tests = new List<ITestCase>();
System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
try
{
foreach (ITestCase test in fixture.CreateTestCases())
{
if (test == null)
continue;
if (!testCaseFilter.Filter(fixture,test))
continue;
ITestCase decoratedTest = DecorateTest(fixture, test);
tests.Add(decoratedTest);
}
testAssembly.AddFixture(fixture, tests);
}
catch (Exception ex)
{
BadFixture badFixture = new BadFixture(fixture.Name, ex);
tests.Clear();
testAssembly.AddFixture(badFixture, tests);
}
}
示例14: Filter
public bool Filter(IFixture fixture, ITestCase test)
{
foreach (string scope in scopes)
if (test.Name.ToLower().StartsWith(scope.ToLower()))
return true;
return false;
}
示例15: ConstructWithNullLoggerThrows
public void ConstructWithNullLoggerThrows(
IFixture fixture)
{
fixture.Inject<ILogger>(null);
var e = Assert.Throws<TargetInvocationException>(() => fixture.Create<NotifyErrorAttribute>());
Assert.IsType<ArgumentNullException>(e.InnerException);
}