本文整理汇总了C#中Fixture类的典型用法代码示例。如果您正苦于以下问题:C# Fixture类的具体用法?C# Fixture怎么用?C# Fixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Fixture类属于命名空间,在下文中一共展示了Fixture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install_should_install_if_a_package_has_not_been_installed_yet
public void Install_should_install_if_a_package_has_not_been_installed_yet()
{
// Arrange
var fixture = new Fixture().Customize(new AutoMoqCustomization());
var proj = fixture.Freeze<Project>();
var pwPkg = new ProjectWidePackage("Prig", "2.0.0", proj);
var mocks = new MockRepository(MockBehavior.Strict);
{
var m = mocks.Create<IVsPackageInstallerServices>();
m.Setup(_ => _.IsPackageInstalledEx(proj, "Prig", "2.0.0")).Returns(false);
m.Setup(_ => _.IsPackageInstalled(proj, "Prig")).Returns(false);
fixture.Inject(m);
}
{
var m = mocks.Create<IVsPackageUninstaller>();
fixture.Inject(m);
}
{
var m = mocks.Create<IVsPackageInstaller>();
m.Setup(_ => _.InstallPackage(default(string), proj, "Prig", "2.0.0", false));
fixture.Inject(m);
}
var pwInstllr = fixture.NewProjectWideInstaller();
// Act
pwInstllr.Install(pwPkg);
// Assert
mocks.VerifyAll();
}
示例2: MessageShouldBeSameAfterSerializationAndDeserialization
public void MessageShouldBeSameAfterSerializationAndDeserialization()
{
var writer = new BinaryWriter(new MemoryStream());
IMessageFactory msgFactory = new MessageFactory(new Message[]
{
new ISomeServiceComplexRequest()
});
var fixture = new Fixture();
fixture.Customize<ISomeServiceComplexRequest>(ob =>
ob.With(x => x.datas,
fixture.CreateMany<SubData>().ToList()));
fixture.Customize<ComplexData>(ob => ob
.With(x => x.SomeArrString, fixture.CreateMany<string>().ToList())
.With(x => x.SomeArrRec, fixture.CreateMany<SubData>().ToList()));
var msg = fixture.CreateAnonymous<ISomeServiceComplexRequest>();
//serialize and deserialize msg1
msg.Serialize(writer);
writer.Seek(0, SeekOrigin.Begin);
var reader = new BinaryReader(writer.BaseStream);
Message retMsg = msgFactory.Deserialize(reader);
retMsg.Should().BeOfType<ISomeServiceComplexRequest>();
msg.ShouldBeEqualTo((ISomeServiceComplexRequest)retMsg);
}
示例3: Save_should_update_an_existing_product
public async Task Save_should_update_an_existing_product()
{
using (var store = NewDocumentStore())
{
using (var session = store.OpenAsyncSession())
{
// Arrange
var fixture = new Fixture();
var product = fixture.Build<Product>()
.With(c => c.Id, "Products-1")
.With(c => c.Name, "Mediums")
.Create();
await SaveEntity(product, session);
// Act
var dto = new ProductDto {Id = "Products-1", Name = "Updated name"};
var service = GetProductsService(session);
var model = await service.Save(dto);
model.Message.Should().Be("Atualizou tipo Updated name");
}
using (var session = store.OpenAsyncSession())
{
var actual = await session.LoadAsync<Product>("Products-1");
actual.Name.Should().Be("Updated name");
}
}
}
示例4: HasImage_Should_Add_ImageNameAttribute
public void HasImage_Should_Add_ImageNameAttribute()
{
var imageName = new Fixture().Create<string>();
_Builder.HasImage(imageName);
A.CallTo(() => _TypeInfo.AddAttribute(A<ImageNameAttribute>.That.Matches(t => t.ImageName == imageName))).MustHaveHappened();
}
示例5: TestEvaluateCancel
public void TestEvaluateCancel()
{
// Arrange
var aFixture = new Fixture();
var expressionContent = aFixture.Create<string>();
var expression = new Expression("not", expressionContent);
var evaluator = new Mock<IExpressionEvaluator>();
var registry = Mock.Of<IEvaluatorSelector>(x => x.GetEvaluator(It.IsAny<Expression>()) == evaluator.Object);
evaluator
.Setup(x => x.Evaluate(It.Is<Expression>(e => e.ToString() == expressionContent),
It.IsAny<RenderingContext>(),
It.IsAny<TalesModel>()))
.Returns(new ExpressionResult(ZptConstants.CancellationToken));
var model = new TalesModel(registry);
var sut = new NotExpressionEvaluator();
// Act
var result = sut.Evaluate(expression, Mock.Of<RenderingContext>(), model);
// Assert
Assert.NotNull(result, "Result nullability");
Assert.AreEqual(true, result.Value, "Correct result");
}
示例6: Execute
public void Execute(Fixture fixture, Action next)
{
foreach (var injectionMethod in fixtures.Keys)
injectionMethod.Invoke(fixture.Instance, new[] { fixtures[injectionMethod] });
next();
}
示例7: Read
public bool Read(XmlReader reader)
{
if(reader.IsStartElement() && reader.Name == "Fixture") {
Fixture fixture = new Fixture();
//...Any attributes go here...
fixture.AllowFrameSkip = bool.Parse(reader.GetAttribute("allowFrameSkip"));
fixture.Name = reader.GetAttribute("name");
// This needs to hold off until after channels are loaded.
string fixtureDefinitionName = reader.GetAttribute("fixtureDefinitionName");
if(reader.ElementsExistWithin("Fixture")) { // Entity element
// Channels
if(reader.ElementsExistWithin("Channels")) { // Container element for child entity
ChannelReader<OutputChannel> channelReader = new ChannelReader<OutputChannel>();
while(channelReader.Read(reader)) {
fixture.InsertChannel(channelReader.Channel);
}
reader.ReadEndElement(); // Channels
}
// With channels loaded, the fixture template reference can be set.
fixture.FixtureDefinitionName = fixtureDefinitionName;
reader.ReadEndElement(); // Fixture
this.Fixture = fixture;
}
return true;
}
return false;
}
示例8: StartPacking_should_create_nupkg
public void StartPacking_should_create_nupkg()
{
// Arrange
var fixture = new Fixture().Customize(new AutoMoqCustomization());
{
var m = new Mock<IEnvironmentRepository>(MockBehavior.Strict);
m.Setup(_ => _.GetNuGetPath()).Returns(AppDomain.CurrentDomain.GetPathInBaseDirectory(@"tools\NuGet.exe"));
fixture.Inject(m);
}
var nugetExecutor = fixture.NewNuGetExecutor();
// Act
var result = nugetExecutor.StartPacking(AppDomain.CurrentDomain.GetPathInBaseDirectory(@"tools\NuGet\Prig.nuspec"), AppDomain.CurrentDomain.BaseDirectory);
// Assert
var lines = result.Split(new[] { "\r\n" }, StringSplitOptions.None);
Assert.LessOrEqual(2, lines.Length);
var match = Regex.Match(lines[1], "'([^']+)'");
Assert.IsTrue(match.Success);
var nupkgPath = match.Groups[1].Value;
Assert.IsTrue(File.Exists(nupkgPath));
Assert.GreaterOrEqual(TimeSpan.FromSeconds(1), DateTime.Now - File.GetLastWriteTime(nupkgPath));
}
示例9: Create
public static TestData Create(int projectCount=5)
{
var fixture = new Fixture();
var returnValue = new TestData
{
Fixture = fixture,
UserName = fixture.Create<string>("UserName"),
ProjectList = fixture.CreateMany<DeployProject>(projectCount).ToList(),
ProjectRoleManager = new Mock<IProjectRoleManager>(),
SystemRoleManager = new Mock<ISystemRoleManager>(),
UserIdentity = new Mock<IUserIdentity>()
};
returnValue.DeployProjectRoleList =
(from i in returnValue.ProjectList
select new DeployProjectRole
{
ProjectId = i.Id,
RoleName = fixture.Create<string>("RoleName")
}
).ToList();
returnValue.ProjectRoleManager.Setup(i => i.GetProjectRoleListForUser(It.IsAny<string>())).Returns(new List<DeployProjectRole>());
returnValue.ProjectRoleManager.Setup(i => i.GetProjectRoleListForUser(returnValue.UserName)).Returns(returnValue.DeployProjectRoleList);
returnValue.SystemRoleManager.Setup(i=>i.GetSystemRoleListForUser(It.IsAny<string>())).Returns(new List<SystemRole>());
returnValue.UserIdentity.Setup(i=>i.UserName).Returns(returnValue.UserName);
returnValue.Sut = new PermissionValidator(returnValue.ProjectRoleManager.Object, returnValue.SystemRoleManager.Object, returnValue.UserIdentity.Object);
return returnValue;
}
示例10: CompileCell
public Cell CompileCell(CellHandling cellHandling, Fixture fixture)
{
_cell = Cell.For(cellHandling, _property, fixture);
_cell.output = true;
return _cell;
}
示例11: Initialize
public void Initialize()
{
fixture = new Fixture();
fixture.Customize<usr_CUSTOMERS>(
customer =>
customer.With(x => x.password, Tests.SAMPLE_PASSWORD).With(x => x.email, Tests.SAMPLE_EMAIL_ADDRESS));
}
示例12: FileSyncTests
public FileSyncTests()
{
_client = new DropNetClient(TestVariables.ApiKey, TestVariables.ApiSecret);
_client.UserLogin = new Models.UserLogin { Token = TestVariables.Token, Secret = TestVariables.Secret };
_fixture = new Fixture();
}
示例13: WriteMappingFragment_should_write_store_entity_set_name
public void WriteMappingFragment_should_write_store_entity_set_name()
{
var fixture = new Fixture();
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entitySet = new EntitySet("ES", "S", null, null, entityType);
var entityContainer = new EntityContainer("EC", DataSpace.SSpace);
entityContainer.AddEntitySetBase(entitySet);
var storageEntitySetMapping
= new EntitySetMapping(
entitySet,
new EntityContainerMapping(entityContainer));
TypeMapping typeMapping = new EntityTypeMapping(storageEntitySetMapping);
var mappingFragment = new MappingFragment(entitySet, typeMapping, false);
fixture.Writer.WriteMappingFragmentElement(mappingFragment);
Assert.Equal(
@"<MappingFragment StoreEntitySet=""ES"" />",
fixture.ToString());
}
示例14: GetById_should_retrieve_a_product_from_the_db
public async Task GetById_should_retrieve_a_product_from_the_db()
{
using (var store = NewDocumentStore())
{
using (var session = store.OpenAsyncSession())
{
// Arrange
var fixture = new Fixture();
var product = fixture.Build<Product>()
.With(c => c.Id, "Products-1")
.With(c => c.Name, "Mediums")
.Create();
await SaveEntity(product, session);
// Act
var service = GetProductsService(session);
var actual = await service.GetById("Products-1");
// Assert
actual.Id.Should().Be("Products-1");
actual.Name.Should().Be("Mediums");
actual.Count.Should().Be(product.Count);
actual.Type.Should().Be(product.Type);
}
}
}
示例15: TestInitialize
public void TestInitialize()
{
_context = new DbTestContext(Settings.Default.MainConnectionString);
_fixture = new Fixture();
_repository = new SenderRepository(new PasswordConverter(), new SqlProcedureExecutor(Settings.Default.MainConnectionString));
}