本文整理汇总了C#中IFixture.Build方法的典型用法代码示例。如果您正苦于以下问题:C# IFixture.Build方法的具体用法?C# IFixture.Build怎么用?C# IFixture.Build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFixture
的用法示例。
在下文中一共展示了IFixture.Build方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMainViewModel
private MainViewModel CreateMainViewModel(IFixture fixture, IMessenger messenger = null)
{
var channel = fixture.Create<IChannel<SaveCmdApplicationConfigurationCommand>>();
fixture.Register<ICmdApplicationConfigurationViewModelFactory>(() => fixture.Create<CmdApplicationConfigurationViewModelFactory>());
fixture.Inject(messenger ?? new Messenger());
return fixture.Build<MainViewModel>().OmitAutoProperties().Create();
}
示例2: ShouldUpdateTags
public static void ShouldUpdateTags( [Frozen] SpPortalLicenseApi portalApi, RandomLicenseFromListFixture license, ExistingTagsFixture tags, IFixture fixture )
{
var valuesForEachDefinedTag = tags.Tags
.Select( ct => fixture.Build<SpPortalLicenseApi.LicenseTag>().With( x => x.Id, ct.Id ).CreateAnonymous() )
.ToList();
var licenseTagsAssignmentHref = license.Selected._embedded.CustomerTags._links.self.href;
var apiResult = portalApi.PutLicenseTags( licenseTagsAssignmentHref, valuesForEachDefinedTag );
Assert.Equal( ResponseStatus.Completed, apiResult.ResponseStatus );
Assert.Equal( HttpStatusCode.Accepted, apiResult.StatusCode );
Verify.EventuallyWithBackOff( () =>
{
//Retrieve the license again (if it was supported, just GETting the tags subresource would be sufficient to prove the point)
var updatedLicense = portalApi.GetLicense( license.Selected._links.self.href );
//Verify that all the tags on the license match
Assert.Equal( ResponseStatus.Completed, updatedLicense.ResponseStatus );
Assert.NotNull( updatedLicense.Data._embedded.CustomerTags.results );
Assert.NotEmpty( updatedLicense.Data._embedded.CustomerTags.results );
// TOOD use xUnit 1.9 and/or Ploeh.semanticComparison to make this cleaner
Assert.Equal(
updatedLicense.Data._embedded.CustomerTags.results.OrderBy( x => x.Id ).Select( x => Tuple.Create( x.Id, x.Value ) ).ToArray(),
valuesForEachDefinedTag.OrderBy( x => x.Id ).Select( x => Tuple.Create( x.Id, x.Value ) ).ToArray() );
} );
}
示例3: Setup
public void Setup()
{
_fixture = new Fixture().Customize(new AutoMoqCustomization());
var container = _fixture.Freeze<Mock<IContainer>>();
_sut =
_fixture.Build<AutoMappingMapper>().FromFactory(
() => new AutoMappingMapper(Mapper.Engine, container.Object)).CreateAnonymous();
}
示例4: GetApplicationConfiguration
private static CmdApplicationConfiguration GetApplicationConfiguration(string applicationName, string friendlyName, IFixture fixture)
{
// TODO: This can be generalized
return fixture.Build<CmdApplicationConfiguration>()
.FromSeed(a => new CmdApplicationConfiguration(
(Name)friendlyName,
(Name)applicationName,
new System.Collections.ObjectModel.ReadOnlyCollection<IParameter>(new List<IParameter>())))
.Create();
}
示例5: Customize
public void Customize(IFixture fixture)
{
//we freeze the HttpRequestContext so that the same context is injected into the controller and the request object
//otherwise, a conflict would happen and an InvalidOperationException would be thrown
var requestContext = fixture.Build<HttpRequestContext>()
.Without(x => x.ClientCertificate)
.Create();
fixture.Inject(requestContext);
}
示例6: GetApplicationConfigurationMeta
private CmdApplicationMeta GetApplicationConfigurationMeta(string applicationName, string friendlyName, IFixture fixture)
{
// TODO: This can be generalized
fixture.Inject<Type>(typeof(IParameter));
return fixture.Build<CmdApplicationMeta>()
.FromSeed(a => new CmdApplicationMeta(
(Name)friendlyName,
(Name)applicationName,
new List<ParameterMeta>()))
.Create();
}
示例7: IdEmptyShouldYieldBadRequest
public static void IdEmptyShouldYieldBadRequest( SpPortalLicenseApi api, IFixture fixture )
{
var badTag = fixture.Build<SpPortalLicenseApi.CustomerTag>().With( x => x.Id, Guid.Empty ).CreateAnonymous();
var response = api.PutCustomerTags( new[] { badTag } );
Assert.Equal( HttpStatusCode.BadRequest, response.StatusCode );
}
示例8: TooLongShouldYieldBadRequest
public static void TooLongShouldYieldBadRequest( SpPortalLicenseApi api, IFixture fixture )
{
var badTag = fixture.Build<SpPortalLicenseApi.CustomerTag>().With( x => x.Name, new String( 'a', 101 ) ).CreateAnonymous();
var response = api.PutCustomerTags( new[] { badTag } );
Assert.Equal( HttpStatusCode.BadRequest, response.StatusCode );
}
示例9: Update_ExistingAdultCustomer_Success_Composed
public void Update_ExistingAdultCustomer_Success_Composed(
[AsAdultPersisted] Customer e,
CustomerManager sut,
IFixture fixture)
{
var data = fixture.Build<CustomerUpdate>()
.With(x => x.ID, e.ID)
.Create();
sut.Update(data);
}
示例10: Update_ExistingAdultCustomer_Success
public void Update_ExistingAdultCustomer_Success(
//warning: the declaring order of the attrs
//does not guarantee that customizations will
//apply in that order, if ordering is required
//then combine multiple customizations using
//CompositeCustomizeAttribute like the example
//below
[Persisted][AsAdult] Customer e,
IFixture fixture,
[Frozen] Mock<ICustomerLogManager> customerLogManager,
CustomerManager sut)
{
var data = fixture.Build<CustomerUpdate>()
.With(x => x.ID, e.ID)
.Create();
sut.Update(data);
customerLogManager.Verify(x => x.LogUpdate(It.Is<Customer>(c => c.ID == data.ID)));
}
示例11: SetUp
public void SetUp()
{
fixture = new Fixture()
.Customize(new AutoMoqCustomization());
maximum = fixture.Create<Position>();
pieceBagMock = fixture.Freeze<Mock<IPieceBag>>();
piece = fixture.Build<FakePiece>()
.With(x => x.Position, new Position(maximum.X - 1, maximum.Y - 1))
.Create();
occupyingPiece = null;
pieceBagMock.Setup(x => x.GetPiece(piece.Position))
.Returns(() => occupyingPiece);
contiguousOpponentPiecesMock = fixture.Freeze<Mock<IContiguousOpponentPieces>>();
fixture.Register(() => new Board(maximum, pieceBagMock.Object, contiguousOpponentPiecesMock.Object));
}
示例12: SetUp
public void SetUp()
{
fixture = new Fixture()
.Customize(new AutoMoqCustomization());
pieceBagMock = fixture.Freeze<Mock<IPieceBag>>();
directionMock = fixture.Freeze<Mock<Direction>>();
startingPiece = fixture.Build<FakePiece>()
.With(x => x.Side, Side.Black)
.Create();
}
示例13: DuplicateValuesShouldBeRejected
public static void DuplicateValuesShouldBeRejected( [Frozen] SpPortalLicenseApi portalApi, RandomLicenseFromListFixture license, ExistingTagsFixture tags, IFixture fixture )
{
var validTagValue = tags.Tags
.Select( ct => fixture.Build<SpPortalLicenseApi.LicenseTag>()
.With( x => x.Id, ct.Id )
.CreateAnonymous() )
.Take( 1 )
.ToArray();
var theSameValueTwice = validTagValue.Concat( validTagValue ).ToArray();
var licenseTagsAssignmentHref = license.Selected._embedded.CustomerTags._links.self.href;
var apiResult = portalApi.PutLicenseTags( licenseTagsAssignmentHref, theSameValueTwice );
Assert.Equal( ResponseStatus.Completed, apiResult.ResponseStatus );
Assert.Equal( HttpStatusCode.InternalServerError, apiResult.StatusCode );
}
示例14: Setup
public void Setup()
{
_fixture = new Fixture().Customize(new AutoMoqCustomization());
_sut = _fixture.Build<Configure>().Without(x => x.Container).CreateAnonymous();//.WithVersion_For_Tests();
_container = _fixture.Freeze<Mock<IContainer>>();
}