• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Fixture类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Fixture的典型用法代码示例。如果您正苦于以下问题:C# Fixture类的具体用法?C# Fixture怎么用?C# Fixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Fixture类属于命名空间,在下文中一共展示了Fixture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
        }
开发者ID:umaranis,项目名称:Prig,代码行数:34,代码来源:ProjectWideInstallerTest.cs


示例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);
        }
开发者ID:tlotter,项目名称:MassiveOnlineUniversalServerEngine,代码行数:27,代码来源:MessageSerializationTests.cs


示例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");
                }
            }
        }
开发者ID:jeremy-holt,项目名称:Cornhouse.Factory-Mutran,代码行数:28,代码来源:ProductServiceTests.cs


示例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();
        }
开发者ID:genesissupsup,项目名称:QuickZ.FluentModelBuilder,代码行数:7,代码来源:ModelBuilderSpecifications.cs


示例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");
        }
开发者ID:csf-dev,项目名称:ZPT-Sharp,代码行数:27,代码来源:TestNotExpressionEvaluator.cs


示例6: Execute

            public void Execute(Fixture fixture, Action next)
            {
                foreach (var injectionMethod in fixtures.Keys)
                    injectionMethod.Invoke(fixture.Instance, new[] { fixtures[injectionMethod] });

                next();
            }
开发者ID:leijiancd,项目名称:fixie,代码行数:7,代码来源:CustomConvention.cs


示例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;
        }
开发者ID:stewmc,项目名称:vixen,代码行数:32,代码来源:FixtureReader.cs


示例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));
        }
开发者ID:umaranis,项目名称:Prig,代码行数:26,代码来源:NuGetExecutorTest.cs


示例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;
				}
开发者ID:gsbastian,项目名称:Sriracha.Deploy,代码行数:31,代码来源:PermissionValidatorTests.cs


示例10: CompileCell

        public Cell CompileCell(CellHandling cellHandling, Fixture fixture)
        {
            _cell = Cell.For(cellHandling, _property, fixture);
            _cell.output = true;

            return _cell;
        }
开发者ID:jamesmanning,项目名称:Storyteller,代码行数:7,代码来源:GetterProperty.cs


示例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));
 }
开发者ID:mamluka,项目名称:JewelryONet,代码行数:7,代码来源:DataBaseCustomerAccountServiceTests.cs


示例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();
        }
开发者ID:Erls-Corporation,项目名称:DropNet,代码行数:7,代码来源:FileSyncTests.cs


示例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());
        }
开发者ID:jesusico83,项目名称:Telerik,代码行数:25,代码来源:MslXmlSchemaWriterTests.cs


示例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);
                }
            }
        }
开发者ID:jeremy-holt,项目名称:Cornhouse.Factory-Mutran,代码行数:26,代码来源:ProductServiceTests.cs


示例15: TestInitialize

		public void TestInitialize()
		{
			_context = new DbTestContext(Settings.Default.MainConnectionString);
			_fixture = new Fixture();

			_repository = new SenderRepository(new PasswordConverter(), new SqlProcedureExecutor(Settings.Default.MainConnectionString));
		}
开发者ID:UHgEHEP,项目名称:test,代码行数:7,代码来源:SenderRepositoryTests.cs


示例16: SetUp

        public void SetUp()
        {
            processor = Builder.CellProcessor();
            processor.Memory.GetItem<Context>().TestPagePath = new FilePath(@"\some\path.html");

            fixture = new Fixture { Processor = processor };
        }
开发者ID:kpartusch,项目名称:fitsharp,代码行数:7,代码来源:FixtureNUnitTest.cs


示例17: CanStoreComplexClient

            public async Task CanStoreComplexClient(NpgsqlClientStore store, Fixture fixture, string clientId)
            {
                // Given
                var client = new Client
                {
                    ClientId = clientId,
                    ClientSecrets = fixture.Create<List<ClientSecret>>(),
                    Flow = Flows.AuthorizationCode,
                    Claims = new List<Claim> { new Claim(fixture.Create("type"), fixture.Create("value"))},
                    AccessTokenType = AccessTokenType.Jwt,
                    ClientUri = fixture.Create<string>(),
                    ClientName = fixture.Create<string>(),
                    RequireConsent = false,
                    ScopeRestrictions = fixture.Create<List<string>>(),
                    LogoUri = fixture.Create<string>(),
                    Enabled = true,
                };

                // When
                await store.AddClientAsync(client);

                // Then
                var fromDb = await store.FindClientByIdAsync(clientId);
                fromDb.ShouldNotBe(null);

                fromDb.ClientId.ShouldBe(clientId);
                fromDb.ClientSecrets.Count.ShouldBe(client.ClientSecrets.Count);
                fromDb.Flow.ShouldBe(client.Flow);
                
            }
开发者ID:soundsmitten,项目名称:IdentityServer3.Postgres,代码行数:30,代码来源:NpgsqlClientStoreTests.cs


示例18: Setup

        public void Setup()
        {
            _fixture = new Fixture();
            _pmGateway = new Mock<IProjectManagerGateway>();
            _projectRepository = new Mock<IProjectRepository>();
            _vcsGateway = new Mock<IVersionControlSystemGateway>();
            _eventSinkMock = new Mock<IEventSink>();
            _userRepository = new Mock<IUserRepository>();
            var paginationSettings = new ProjectManagement.Domain.PaginationSettings(10);

            _pmGateway
                .Setup(pm => pm.CreateProject(It.IsAny<CreateProjectRequest>()))
                .Returns(_fixture.Create<RedmineProjectInfo>());
            _vcsGateway
                .Setup(vcs => vcs.CreateRepositoryForProject(It.IsAny<CreateProjectRequest>()))
                .Returns(_fixture.Create<VersionControlSystemInfo>());
            _projectRepository
                .Setup(repo => repo.SaveProject(It.IsAny<Project>()))
                .Returns(1);
            _userRepository.Setup(repo => repo.GetUserRedmineId(It.IsAny<int>())).Returns(1);
            _userRepository.Setup(repo => repo.GetUserGitlabId(It.IsAny<int>())).Returns(1);
            _projectProvider = new ProjectProvider(
                _pmGateway.Object,
                _vcsGateway.Object,
                _projectRepository.Object,
                _eventSinkMock.Object,
                _userRepository.Object,
                paginationSettings,
                new IssuePaginationSettings(25));
        }
开发者ID:LeagueOfDevelopers,项目名称:LodCore,代码行数:30,代码来源:ProjectProviderTests.cs


示例19: DoTable

        public void DoTable(Fixture fixture, Parse tables, object[] businessObjects, int right, int wrong, int ignores, int exceptions)
        {
            BusinessObjectRowFixture.objects = businessObjects;
            RunTest(fixture, tables);

            TestUtils.CheckCounts(resultCounts, right, wrong, ignores, exceptions);
        }
开发者ID:GibSral,项目名称:fitsharp,代码行数:7,代码来源:RowFixtureTest.cs


示例20: WriteFunctionElementHeader_should_not_write_return_type_attribute_for_non_primitive_return_type

        public void WriteFunctionElementHeader_should_not_write_return_type_attribute_for_non_primitive_return_type()
        {
            var fixture = new Fixture();

            var returnParameterType = TypeUsage.CreateDefaultTypeUsage(new RowType());

            var function = new EdmFunction(
                "Foo",
                "Bar",
                DataSpace.SSpace,
                new EdmFunctionPayload
                    {
                        Schema = "dbo",
                        ReturnParameters =
                            new[]
                                {
                                    new FunctionParameter(
                                        "r",
                                        returnParameterType,
                                        ParameterMode.ReturnValue)
                                }
                    });

            fixture.Writer.WriteFunctionElementHeader(function);

            Assert.Equal(
                "<Function Name=\"Foo\" Aggregate=\"false\" BuiltIn=\"false\" NiladicFunction=\"false\" IsComposable=\"true\" ParameterTypeSemantics=\"AllowImplicitConversion\" Schema=\"dbo\"",
                fixture.ToString());
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:29,代码来源:EdmXmlSchemaWriterTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FixupContext类代码示例发布时间:2022-05-24
下一篇:
C# FixedStatement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap