|
| 1 | +using System; |
| 2 | +using Shouldly; |
| 3 | +using TestStack.Dossier.Factories; |
| 4 | +using TestStack.Dossier.Tests.Stubs.Entities; |
| 5 | +using TestStack.Dossier.Tests.Stubs.ViewModels; |
| 6 | +using Xunit; |
| 7 | + |
| 8 | +namespace TestStack.Dossier.Tests.Factories |
| 9 | +{ |
| 10 | + public class FactoryTests |
| 11 | + { |
| 12 | + [Fact] |
| 13 | + public void GivenAllPropertiesFactory_WhenBuilding_ThenAllPropertiesSet() |
| 14 | + { |
| 15 | + InstructorViewModel instructor = Builder<InstructorViewModel>.CreateNew(new AllPropertiesFactory()); |
| 16 | + |
| 17 | + // ctor properties |
| 18 | + instructor.Id.ShouldNotBe(Guid.Empty); |
| 19 | + instructor.FirstName.ShouldNotBe(null); |
| 20 | + instructor.LastName.ShouldNotBe(null); |
| 21 | + |
| 22 | + // public properties |
| 23 | + instructor.Room.ShouldNotBe(null); |
| 24 | + instructor.NumberOfStudents.ShouldNotBe(0); |
| 25 | + |
| 26 | + // private properties |
| 27 | + instructor.Subject.ShouldNotBe(null); |
| 28 | + instructor.YearsAtSchool.ShouldNotBe(0); |
| 29 | + } |
| 30 | + |
| 31 | + [Fact] |
| 32 | + public void GivenAutoFixtureFactory_WhenBuilding_ThenOnlyConstructorAndPublicPropertiesSet() |
| 33 | + { |
| 34 | + InstructorViewModel instructor = Builder<InstructorViewModel>.CreateNew(new AutoFixtureFactory()); |
| 35 | + |
| 36 | + // ctor properties |
| 37 | + instructor.Id.ShouldNotBe(Guid.Empty); |
| 38 | + instructor.FirstName.ShouldNotBe(null); |
| 39 | + instructor.LastName.ShouldNotBe(null); |
| 40 | + |
| 41 | + // public properties |
| 42 | + instructor.Room.ShouldNotBe(null); |
| 43 | + instructor.NumberOfStudents.ShouldNotBe(0); |
| 44 | + |
| 45 | + // private properties |
| 46 | + instructor.Subject.ShouldBe(null); |
| 47 | + instructor.YearsAtSchool.ShouldBe(0); |
| 48 | + } |
| 49 | + |
| 50 | + [Fact] |
| 51 | + public void GivenConstructorPropertiesFactory_WhenBuilding_ThenOnlyConstructorPropertiesSet() |
| 52 | + { |
| 53 | + InstructorViewModel instructor = Builder<InstructorViewModel>.CreateNew(new ConstructorFactory()); |
| 54 | + |
| 55 | + // ctor properties |
| 56 | + instructor.Id.ShouldNotBe(Guid.Empty); |
| 57 | + instructor.FirstName.ShouldNotBe(null); |
| 58 | + instructor.LastName.ShouldNotBe(null); |
| 59 | + |
| 60 | + // public properties |
| 61 | + instructor.Room.ShouldBe(null); |
| 62 | + instructor.NumberOfStudents.ShouldBe(0); |
| 63 | + |
| 64 | + // private properties |
| 65 | + instructor.Subject.ShouldBe(null); |
| 66 | + instructor.YearsAtSchool.ShouldBe(0); |
| 67 | + } |
| 68 | + |
| 69 | + [Fact] |
| 70 | + public void GivenPublicPropertiesFactory_WhenBuilding_ThenOnlyConstructorAndPublicPropertiesSet() |
| 71 | + { |
| 72 | + InstructorViewModel instructor = Builder<InstructorViewModel>.CreateNew(new PublicPropertiesFactory()); |
| 73 | + |
| 74 | + // ctor properties |
| 75 | + instructor.Id.ShouldNotBe(Guid.Empty); |
| 76 | + instructor.FirstName.ShouldNotBe(null); |
| 77 | + instructor.LastName.ShouldNotBe(null); |
| 78 | + |
| 79 | + // public properties |
| 80 | + instructor.Room.ShouldNotBe(null); |
| 81 | + instructor.NumberOfStudents.ShouldBeGreaterThan(0); |
| 82 | + |
| 83 | + // private properties |
| 84 | + instructor.Subject.ShouldBe(null); |
| 85 | + instructor.YearsAtSchool.ShouldBe(0); |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments