示例#1
0
 public void autodata_demo()
 {
     var fixture = new Fixture();
     fixture.Customize(new AutoNSubstituteCustomization());
     var service = fixture.Create<UserService>();
     service.Should().NotBeNull();
 }
示例#2
0
        public void CustomizeFixture_NoWithout()
        {
            // Arrange
            var fixture = new Fixture();
            fixture.Customize<Employee>(ob => ob
                .Do(AssignRandomEmployeeType));

            // Act
            var employee = fixture.Create<Employee>();

            // Assert
            var inList = _names.Contains(employee.Name);
            Assert.IsTrue(inList); // Will always fail because the action executed in Do is overwritten by Autofixture
        }
示例#3
0
        public void CustomizeFixture_WithWithout()
        {
            // Arrange
            var fixture = new Fixture();
            fixture.Customize<Employee>(ob => ob
                .Without(e => e.Name)
                .Do(AssignRandomEmployeeType));

            // Act
            var employee = fixture.Create<Employee>();

            // Assert
            var inList = _names.Contains(employee.Name);
            Assert.IsTrue(inList);
        }