当前位置: 首页>>代码示例>>C#>>正文


C# Fixture.CreateAnonymous方法代码示例

本文整理汇总了C#中Fixture.CreateAnonymous方法的典型用法代码示例。如果您正苦于以下问题:C# Fixture.CreateAnonymous方法的具体用法?C# Fixture.CreateAnonymous怎么用?C# Fixture.CreateAnonymous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fixture的用法示例。


在下文中一共展示了Fixture.CreateAnonymous方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: SynchronizePatientAccount_GivenPatientWithoutExistingBillingOffice_ThrowsArgumentException

        public void SynchronizePatientAccount_GivenPatientWithoutExistingBillingOffice_ThrowsArgumentException()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                var fixture = new Fixture ().Customize ( new AutoMoqCustomization () );

                var billingOfficeRepository = new Mock<IBillingOfficeRepository> ();
                billingOfficeRepository.Setup ( p => p.GetByAgencyKey ( It.IsAny<long> () ) ).Returns ( () => null );
                fixture.Register ( () => billingOfficeRepository.Object );

                var agencyProfile = fixture.CreateAnonymous<AgencyProfile> ();

                var agency = new Mock<Agency> ();
                agency.SetupGet(p => p.Key).Returns(fixture.CreateAnonymous<long>());
                agency.SetupGet ( p => p.AgencyProfile ).Returns ( agencyProfile );

                var patient = new Mock<Patient> ();
                patient.SetupGet(p => p.Key).Returns(fixture.CreateAnonymous<long>());
                patient.SetupGet ( p => p.Agency ).Returns ( agency.Object );

                var patientAccountSynchronizationService = fixture.CreateAnonymous<PatientAccountSynchronizationService> ();

                // Exercise
                patientAccountSynchronizationService.SynchronizePatientAccount ( patient.Object );

                // Verify
            }
        }
开发者ID:divyang4481,项目名称:REM,代码行数:29,代码来源:PatientAccountSynchronizationServiceTests.cs

示例3: InnerCurrencyIsOnlyInvokedOnceDespiteMultipleCalls

        public void InnerCurrencyIsOnlyInvokedOnceDespiteMultipleCalls()
        {
            // Fixture setup
            var fixture = new Fixture();
            var exchangeRate = fixture.CreateAnonymous<decimal>();
            var sourceCurrencyCode = fixture.CreateAnonymous("CurrencyCode");
            var destinationCurrencyCode = fixture.CreateAnonymous("CurrencyCode");

            var currencyMock = new Mock<Currency>();
            currencyMock.Setup(c => c.GetExchangeRateFor(It.IsAny<string>())).Returns(exchangeRate).Verifiable();

            var currencyProviderStub = new Mock<CurrencyProvider>();
            currencyProviderStub.Setup(cp => cp.GetCurrency(sourceCurrencyCode)).Returns(currencyMock.Object);
            fixture.Register(() => currencyProviderStub.Object);

            fixture.Register(() => TimeSpan.FromMinutes(1));

            var sut = fixture.CreateAnonymous<CachingCurrencyProvider>();
            // Exercise system
            sut.GetCurrency(sourceCurrencyCode).GetExchangeRateFor(destinationCurrencyCode);
            sut.GetCurrency(sourceCurrencyCode).GetExchangeRateFor(destinationCurrencyCode);
            // Verify outcome
            currencyMock.Verify(c => c.GetExchangeRateFor(destinationCurrencyCode), Times.Once());
            // Teardown
        }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:25,代码来源:CachingCurrencyProviderTest.cs

示例4: SynchronizeService_DiagnosisIsChanged_RevisesDiagnosisCorrectly

        public void SynchronizeService_DiagnosisIsChanged_RevisesDiagnosisCorrectly()
        {
            // Setup
            var fixture = new Fixture().Customize(new AutoMoqCustomization());

            var encounter = new Mock<Encounter>();
            var procedure = new Mock<Procedure>();
            procedure.SetupGet(p => p.ProcedureType).Returns(ProcedureType.Activity);
            var diagnosis = fixture.CreateAnonymous<CodedConcept>();

            var service = new Mock<Service>();
            var serviceDiagnosis = fixture.CreateAnonymous<CodedConcept> ();
            service.SetupGet ( p => p.Diagnosis ).Returns ( serviceDiagnosis );
            service.SetupGet ( p => p.Encounter ).Returns ( encounter.Object );

            var serviceRepository = new Mock<IServiceRepository>();
            serviceRepository.Setup(p => p.GetByTrackingNumber(It.IsAny<long>())).Returns(service.Object);
            fixture.Register(() => serviceRepository.Object);

            var medicalProcedure = fixture.CreateAnonymous<MedicalProcedure>();
            var medicalProcedureTranslator = new Mock<IMedicalProcedureTranslator>();
            medicalProcedureTranslator.Setup(p => p.Translate(It.IsAny<Procedure>())).Returns(medicalProcedure);
            fixture.Register(() => medicalProcedureTranslator);

            var serviceFactory = new Mock<IServiceFactory>();
            fixture.Register(() => serviceFactory);

            var serviceSynchronizationService = fixture.CreateAnonymous<ServiceSynchronizationService>();

            // Exercise
            serviceSynchronizationService.SynchronizeService(encounter.Object, procedure.Object, diagnosis);

            // Verify
            service.Verify(p => p.ReviseDiagnosis(diagnosis));
        }
开发者ID:divyang4481,项目名称:REM,代码行数:35,代码来源:ServiceSynchronizationServiceTests.cs

示例5: BeforeEach

 public void BeforeEach()
 {
     _fixture = new Fixture();
     _inspectionLookup = Mock.Of<IVehicleInspectionLookup>(x =>
         x.ByRegistration(It.IsAny<RegistrationNumber>()) == _fixture.CreateAnonymous<Vehicle>() &&
         x.ByVehicleIdentificationNumber(It.IsAny<VehicleIdentificationNumber>()) == _fixture.CreateAnonymous<Vehicle>());
     _sut = new VehicleInspectionService(_inspectionLookup);
 }
开发者ID:driis,项目名称:VehicleInspectionReports,代码行数:8,代码来源:VehicleInspectionServiceTests.cs

示例6: NoSePuedeCrearUnPeriodoConFinMenorQueInicio

        public void NoSePuedeCrearUnPeriodoConFinMenorQueInicio()
        {
            var fixture = new Fixture();
            var fin = fixture.CreateAnonymous<DateTime>();
            var inicio = fixture.CreateAnonymous<DateTime>();

            Assert.Throws<InvalidOperationException>(() => new Periodo(inicio, fin));
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:8,代码来源:PeriodoTests.cs

示例7: UnPeriodoIniciadoNoSePuedeTerminarConFinMenorQueInicio

        public void UnPeriodoIniciadoNoSePuedeTerminarConFinMenorQueInicio()
        {
            var fixture = new Fixture();
            var fin = fixture.CreateAnonymous<DateTime>();
            var inicio = fixture.CreateAnonymous<DateTime>();
            var sut = new Periodo(inicio);

            Assert.Throws<InvalidOperationException>(() => sut.Finalizar(fin));
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:9,代码来源:PeriodoTests.cs

示例8: addMovement_returns_valid_instance_with_valid_inputs

 public void addMovement_returns_valid_instance_with_valid_inputs()
 {
     var fixture = new Fixture();
     fixture.Register(UnLocodeHelpers.GetNewUnLocode);
     var voyageBuilder = fixture.CreateAnonymous<VoyageBuilder>();
     var arrivalLocation = fixture.CreateAnonymous<BookingApi.Domain.Location.Location>();
     var departureTime = fixture.CreateAnonymous<DateTime>();
     var arrivalTime = fixture.CreateAnonymous<DateTime>();
     Assert.NotNull(voyageBuilder.AddMovement(arrivalLocation, departureTime, arrivalTime));
 }
开发者ID:tjaskula,项目名称:CargoShippingDDD,代码行数:10,代码来源:VoyageBuilderTests.cs

示例9: UnPeriodoConFinNoEstaIniciado

        public void UnPeriodoConFinNoEstaIniciado()
        {
            var fixture = new Fixture();
            var inicio = fixture.CreateAnonymous<DateTime>();
            var fin = fixture.CreateAnonymous<DateTime>();
            var sut = new Periodo(inicio, fin);

            sut.Inicio.Should().Be(inicio);
            sut.Fin.Should().Be(fin);
            sut.EstaIniciado.Should().BeFalse();
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:11,代码来源:PeriodoTests.cs

示例10: UnaJornadaIniciadaConUltimaPausaIniciadaTienePausaIniciada

        public void UnaJornadaIniciadaConUltimaPausaIniciadaTienePausaIniciada()
        {
            var fixture = new Fixture();
            var inicioJornada = fixture.CreateAnonymous<DateTime>();
            var inicioPausa = fixture.CreateAnonymous<DateTime>();
            var pausa = new Pausa(inicioPausa);

            var sut = new Jornada(inicioJornada, pausa);

            sut.PausaIniciada.Should().NotBeNull();
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:11,代码来源:JornadaTests.cs

示例11: NoSePuedeCrearJornadaIniciadaConPausasAnterioresAFechaInicio

        public void NoSePuedeCrearJornadaIniciadaConPausasAnterioresAFechaInicio()
        {
            var fixture = new Fixture();
            var inicioPausa = fixture.CreateAnonymous<DateTime>();
            var finPausa = fixture.CreateAnonymous<DateTime>();
            var inicioJornada = fixture.CreateAnonymous<DateTime>();
            var pausa = new Pausa(inicioPausa, finPausa);

            Assert.Throws<InvalidOperationException>(
                () => new Jornada(inicioJornada, pausa));
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:11,代码来源:JornadaTests.cs

示例12: NoSePuedeCrearJornadaTerminadaConPausasFueraDeLasFechasDeLaJornada3

        public void NoSePuedeCrearJornadaTerminadaConPausasFueraDeLasFechasDeLaJornada3()
        {
            var fixture = new Fixture();
            var inicioPausa = fixture.CreateAnonymous<DateTime>();
            var inicioJornada = fixture.CreateAnonymous<DateTime>();
            var finJornada = fixture.CreateAnonymous<DateTime>();
            var finPausa = fixture.CreateAnonymous<DateTime>();
            var pausa = new Pausa(inicioPausa, finPausa);

            Assert.Throws<InvalidOperationException>(
                () => new Jornada(inicioJornada, finJornada, pausa));
        }
开发者ID:hbiarge,项目名称:Testing-HackLab,代码行数:12,代码来源:JornadaTests.cs

示例13: RevisePhones_GivenAPhoneListAndPatientAccountHasPhones_RevisesPhonesCorrectly

        public void RevisePhones_GivenAPhoneListAndPatientAccountHasPhones_RevisesPhonesCorrectly()
        {
            // Setup
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            var address = new Address (
                fixture.CreateAnonymous<string> (),
                fixture.CreateAnonymous<string> (),
                fixture.CreateAnonymous<string> (),
                new Mock<CountyArea> ().Object,
                new Mock<StateProvince> ().Object,
                new Mock<Country> ().Object,
                new PostalCode ( "21046" ) );
            var patientAccount = new PatientAccount (
                new Mock<BillingOffice> ().Object,
                fixture.CreateAnonymous<long> (),
                fixture.CreateAnonymous<PersonName> (),
                fixture.CreateAnonymous<DateTime> (),
                address,
                new Mock<AdministrativeGender> ().Object );

            var patientAccountPhoneType1 = new Mock<PatientAccountPhoneType> ();
            patientAccountPhoneType1.SetupGet ( p => p.Key ).Returns ( fixture.CreateAnonymous<long> () );

            var patientAccountPhoneType2 = new Mock<PatientAccountPhoneType> ();
            patientAccountPhoneType2.SetupGet ( p => p.Key ).Returns ( fixture.CreateAnonymous<long> () );

            var patientAccountPhoneType3 = new Mock<PatientAccountPhoneType> ();
            patientAccountPhoneType3.SetupGet ( p => p.Key ).Returns ( fixture.CreateAnonymous<long> () );

            var phone = fixture.CreateAnonymous<Phone> ();

            var patientAccountPhone1 = new PatientAccountPhone ( patientAccountPhoneType1.Object, phone );
            var sameAsPatientAccountPhone1 = new PatientAccountPhone(patientAccountPhoneType1.Object, phone);

            var patientAccountPhone2 = new PatientAccountPhone(patientAccountPhoneType2.Object, phone);

            var patientAccountPhone3 = new PatientAccountPhone(patientAccountPhoneType3.Object, phone);

            var initialPhoneList = new List<PatientAccountPhone> { patientAccountPhone1, patientAccountPhone2 };
            patientAccount.RevisePhones(initialPhoneList);

            var inputPhoneList = new List<PatientAccountPhone> { sameAsPatientAccountPhone1, patientAccountPhone3 };

            // Exercise
            patientAccount.RevisePhones(inputPhoneList);

            // Verify
            Assert.AreEqual(2, patientAccount.Phones.Count());
            Assert.IsTrue(patientAccount.Phones.Contains(patientAccountPhone1));
            Assert.IsFalse(patientAccount.Phones.Contains(patientAccountPhone2));
            Assert.IsTrue(patientAccount.Phones.Contains(patientAccountPhone3));
        }
开发者ID:divyang4481,项目名称:REM,代码行数:52,代码来源:PatientAccountTests.cs

示例14: QuantityIsWellBehavedWritableProperty

 public void QuantityIsWellBehavedWritableProperty()
 {
     // Fixture setup
     var fixture = new Fixture();
     var sut = fixture.CreateAnonymous<Extent>();
     var expectedQuantity = fixture.CreateAnonymous<int>();
     // Exercise system
     sut.Quantity = expectedQuantity;
     int result = sut.Quantity;
     // Verify outcome
     Assert.Equal<int>(expectedQuantity, result);
     // Teardown
 }
开发者ID:mesta1,项目名称:dli.net_sourcecode,代码行数:13,代码来源:ExtentTest.cs

示例15: IntroductoryTest

        public void IntroductoryTest()
        {
            // Fixture setup
            Fixture fixture = new Fixture();

            int expectedNumber = fixture.CreateAnonymous<int>();
            MyClass sut = fixture.CreateAnonymous<MyClass>();
            // Exercise system
            int result = sut.Echo(expectedNumber);
            // Verify outcome
            Assert.Equal<int>(expectedNumber, result);
            // Teardown
        }
开发者ID:rajeshgupthar,项目名称:AutoFixture,代码行数:13,代码来源:DocumentationExample.cs


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