autofixture

AutoFixture mixing PropertyData with multiple entries and AutoData (using AutoMoqCustomization)

一个人想着一个人 提交于 2019-12-23 03:15:09
问题 I've looked at both of these similar SO questions: AutoFixture: PropertyData and heterogeneous parameters AutoFixture CompositeDataAttribute does not work with PropertyDataAttribute And they're awesome and get me nearly there. But both examples use only one entry in the emitted IEnumerable PropertyData (i.e.: yield return new object[] { 2, 4 }; -- see: https://stackoverflow.com/a/16843837/201308) This works, but it blows up whenever I want to do test over more than one object[] test data. I

AutoFixture mixing PropertyData with multiple entries and AutoData (using AutoMoqCustomization)

左心房为你撑大大i 提交于 2019-12-23 03:15:09
问题 I've looked at both of these similar SO questions: AutoFixture: PropertyData and heterogeneous parameters AutoFixture CompositeDataAttribute does not work with PropertyDataAttribute And they're awesome and get me nearly there. But both examples use only one entry in the emitted IEnumerable PropertyData (i.e.: yield return new object[] { 2, 4 }; -- see: https://stackoverflow.com/a/16843837/201308) This works, but it blows up whenever I want to do test over more than one object[] test data. I

Fixture.CreateAnonymous method kills test runner process with an error (AutoFixture) when using AutoMoq to create a Controller

偶尔善良 提交于 2019-12-22 13:08:10
问题 I'm trying to use the AutoMoqCustomization with AutoFixture to create an ASP.NET MVC2 Controller in a unit test via the Fixture.CreateAnonymous method. I've tried in both xUnit under TestDriven.NET, the xUnit test GUI and in MSTest and all have the same result: a massive failure of the process running the test. On Windows 7 x64 if that matters. To reproduce, simply create a new ASP.NET MVC2 project, add the references to AutoFixture, AutoMoq and Moq (3.1, as per the AutoMoq source) and try

Testing With A Fake DbContext and Autofixture and Moq

徘徊边缘 提交于 2019-12-22 08:29:26
问题 SO follow this example example and how make a fake DBContex For test my test using just this work fine [Test] public void CiudadIndex() { var ciudades = new FakeDbSet<Ciudad> { new Ciudad {CiudadId = 1, EmpresaId =1, Descripcion ="Santa Cruz", FechaProceso = DateTime.Now, MarcaBaja = null, UsuarioId = 1}, new Ciudad {CiudadId = 2, EmpresaId =1, Descripcion ="La Paz", FechaProceso = DateTime.Now, MarcaBaja = null, UsuarioId = 1}, new Ciudad {CiudadId = 3, EmpresaId =1, Descripcion ="Cochabamba

Invoke Dispose method on AutoFixture customization

我与影子孤独终老i 提交于 2019-12-22 05:04:48
问题 I'm using an AutoFixture customization to test a repository which access to a SQL Compact DB. Would be very helpful to me to delete this database as soon as the test is completed. Because the db is created in the customization constructor I think that the best place to delete it is in the dispose method. The code which I'm thinking is: internal class ProjectRepositoryCustomization : ICustomization { private readonly String _dbLocation; public ProjectRepositoryCustomization() { var

AutoFixture: how to CreateAnonymous from a System.Type

戏子无情 提交于 2019-12-21 06:58:16
问题 I need to create an object from AutoFixture using nothing more than a System.Type. However, there doesn't appear to be an overload of CreateAnonymous() that simply takes a type. They all expect a compile time generic T. Is there a way to convert a System.Type to T? Edit with usage details: I'm using AutoMapper, which has a hook for injecting components to support complex mapping scenarios: void ConstructServicesUsing(System.Func<Type,object> constructor) As you can see from the signature,

AutoFixture/AutoMoq ignores injected instance/frozen mock

别说谁变了你拦得住时间么 提交于 2019-12-21 03:53:18
问题 The short takeaway now that the solution has been found: AutoFixture returns frozen the mock just fine; my sut that was also generated by AutoFixture just had a public property with a local default that was important for the test and that AutoFixture set to a new value. There is much to learn beyond that from Mark's answer. Original question: I started trying out AutoFixture yesterday for my xUnit.net tests that have Moq all over them. I was hoping to replace some of the Moq stuff or make it

Example of how to use AutoFixture with NSubstitute

耗尽温柔 提交于 2019-12-21 03:28:19
问题 I use NSubstitute a lot. And I love it. I am just looking into AutoFixture. It seems great! I have seen AutoFixture for NSubstitute and seen a few examples in Moq on how to use this feature. But I can't seem to translate it into NSubstitute. I tried this: var fixture = new Fixture().Customize(new AutoNSubstituteCustomization()); var addDest = Substitute.For<IPerson>(); Using: public interface IPersonEntity { int ID { get; set; } string FirstName { get; set;} string LastName { get; set;}

AutoFixture constrained string parameter

∥☆過路亽.° 提交于 2019-12-20 04:31:38
问题 Is there a simple way to specify a list of possible values for the parameter orderBy? Not one by one please, otherwise I would not be making the question. I want to specify that orderby makes sense only if it is chosen from a predetermined list. Suppose the list is very large...still not random. This cannot be that hard...no single example of such a simple task. [Test, AutoData] public override void IndexReturnsView(int? pageIndex, int? pageSize, string orderBy, bool? desc) { ..... } EDIT:

Using autofixture in my data integration tests to create proxies

偶尔善良 提交于 2019-12-19 19:54:38
问题 I'm trying to write a suite of database integration tests for my domain which uses Entity Framework. I would prefer to autofixture objects in some scenarios. My ideal syntax would be something like [TestMethod] public void AutofixtureMyEntityEntity() { var fixture = new Fixture(); fixture.Customize<MyEntity>( c => c.FromFactory<MyDbContext>(ctx => ctx.Set<MyEntity>().Create())); using (var context = new MyDbContext()) { fixture.Inject(context); var entity = fixture.CreateAnonymous<MyEntity>()