本文整理汇总了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);
}
示例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
}
}
示例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
}
示例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));
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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();
}
示例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();
}
示例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));
}
示例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));
}
示例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));
}
示例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
}
示例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
}