public void CreateFromNullSpecimenContextThrows()
 {
     // Arrange
     // Act & assert
     Assert.Throws <ArgumentNullException>(() =>
                                           SpecimenFactory.Create <object>((ISpecimenContext)null));
 }
        public void CreateWillReturnCorrectResult()
        {
            // Fixture setup
            var expectedSpecimen = new object();

            var param1 = new { ExpectedRequest = typeof(decimal), Specimen = (object)1m };
            var param2 = new { ExpectedRequest = typeof(TimeSpan), Specimen = (object)TimeSpan.FromDays(1) };
            var subRequests = new[] { param1, param2 };

            var container = new DelegatingSpecimenContext();
            container.OnResolve = r => (from x in subRequests
                                        where x.ExpectedRequest.Equals(r)
#pragma warning disable 618
                                        select x.Specimen).DefaultIfEmpty(new NoSpecimen(r)).SingleOrDefault();
#pragma warning restore 618

            Func<decimal, TimeSpan, object> f = (d, ts) => param1.Specimen.Equals(d) && param2.Specimen.Equals(ts) ? expectedSpecimen : new NoSpecimen();
            var sut = new SpecimenFactory<decimal, TimeSpan, object>(f);
            // Exercise system
            var dummyRequest = new object();
            var result = sut.Create(dummyRequest, container);
            // Verify outcome
            Assert.Equal(expectedSpecimen, result);
            // Teardown
        }
        public void CreateWillReturnCorrectResult()
        {
            // Arrange
            var expectedSpecimen = new object();

            var param1      = new { ExpectedRequest = typeof(decimal), Specimen = (object)1m };
            var param2      = new { ExpectedRequest = typeof(TimeSpan), Specimen = (object)TimeSpan.FromDays(1) };
            var param3      = new { ExpectedRequest = typeof(string), Specimen = (object)"Anonymous value - with Foo!" };
            var subRequests = new[] { param1, param2, param3 };

            var container = new DelegatingSpecimenContext();

            container.OnResolve = r => (from x in subRequests
                                        where x.ExpectedRequest.Equals(r)
                                        select x.Specimen).DefaultIfEmpty(new NoSpecimen()).SingleOrDefault();

            Func <decimal, TimeSpan, string, object> f = (d, ts, s) =>
                                                         param1.Specimen.Equals(d) && param2.Specimen.Equals(ts) && param3.Specimen.Equals(s) ? expectedSpecimen : new NoSpecimen();
            var sut = new SpecimenFactory <decimal, TimeSpan, string, object>(f);
            // Act
            var dummyRequest = new object();
            var result       = sut.Create(dummyRequest, container);

            // Assert
            Assert.Equal(expectedSpecimen, result);
        }
        public void CreateWillReturnCorrectResult()
        {
            // Fixture setup
            var expectedSpecimen = new object();

            var param1      = new { ExpectedRequest = typeof(decimal), Specimen = (object)1m };
            var param2      = new { ExpectedRequest = typeof(TimeSpan), Specimen = (object)TimeSpan.FromDays(1) };
            var subRequests = new[] { param1, param2 };

            var container = new DelegatingSpecimenContext();

            container.OnResolve = r => (from x in subRequests
                                        where x.ExpectedRequest.Equals(r)
#pragma warning disable 618
                                        select x.Specimen).DefaultIfEmpty(new NoSpecimen(r)).SingleOrDefault();
#pragma warning restore 618

            Func <decimal, TimeSpan, object> f = (d, ts) => param1.Specimen.Equals(d) && param2.Specimen.Equals(ts) ? expectedSpecimen : new NoSpecimen();
            var sut = new SpecimenFactory <decimal, TimeSpan, object>(f);
            // Exercise system
            var dummyRequest = new object();
            var result       = sut.Create(dummyRequest, container);
            // Verify outcome
            Assert.Equal(expectedSpecimen, result);
            // Teardown
        }
        public void CreateWillReturnCorrectResult()
        {
            // Fixture setup
            var expectedSpecimen = new object();

            var param1 = new { ExpectedRequest = typeof(decimal), Specimen = (object)1m };
            var param2 = new { ExpectedRequest = typeof(TimeSpan), Specimen = (object)TimeSpan.FromDays(1) };
            var param3 = new { ExpectedRequest = typeof(string), Specimen = (object)"Anonymous value - with Foo!" };
            var param4 = new { ExpectedRequest = typeof(int), Specimen = (object)7 };
            var subRequests = new[] { param1, param2, param3, param4 };

            var container = new DelegatingSpecimenContext();
            container.OnResolve = r => (from x in subRequests
                                        where x.ExpectedRequest.Equals(r)
                                        select x.Specimen).DefaultIfEmpty(new NoSpecimen(r)).SingleOrDefault();

            Func<decimal, TimeSpan, string, int, object> f = (d, ts, s, i) =>
                param1.Specimen.Equals(d) && param2.Specimen.Equals(ts) && param3.Specimen.Equals(s) && param4.Specimen.Equals(i) ? expectedSpecimen : new NoSpecimen();
            var sut = new SpecimenFactory<decimal, TimeSpan, string, int, object>(f);
            // Exercise system
            var dummyRequest = new object();
            var result = sut.Create(dummyRequest, container);
            // Verify outcome
            Assert.Equal(expectedSpecimen, result);
            // Teardown
        }
 public void CreateAnonymousFromNullSpecimenContextThrows()
 {
     // Fixture setup
     // Exercise system and verify outcome
     Assert.Throws <ArgumentNullException>(() =>
                                           SpecimenFactory.CreateAnonymous <object>((ISpecimenContext)null));
     // Teardown
 }
 public void CreateManyOnNullSpecimenBuilderComposerThrows()
 {
     // Fixture setup
     // Exercise system and verify outcome
     Assert.Throws <ArgumentNullException>(() =>
                                           SpecimenFactory.CreateMany <object>((ISpecimenBuilderComposer)null));
     // Teardown
 }
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     Func<object> dummyFunc = () => new object();
     // Exercise system
     var sut = new SpecimenFactory<object>(dummyFunc);
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
        public void CreateManyOnNullSpecimenContextWithSeedThrows()
        {
            // Fixture setup
            var dummySeed = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  SpecimenFactory.CreateMany <object>((ISpecimenContext)null, dummySeed));
            // Teardown
        }
        public void CreateWithNullContainerThrows()
        {
            // Arrange
            var sut          = new SpecimenFactory <object, object, object, object>((x, y, z) => x);
            var dummyRequest = new object();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
        }
        public void CreateAnonymousFromNullSpecimenBuilderComposerWithSeedThrows()
        {
            // Fixture setup
            var dummySeed = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  SpecimenFactory.CreateAnonymous <object>((ISpecimenBuilderComposer)null, dummySeed));
            // Teardown
        }
 public void CreateWithNullContainerThrows()
 {
     // Fixture setup
     var sut = new SpecimenFactory<object, object>(x => x);
     var dummyRequest = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Create(dummyRequest, null));
     // Teardown
 }
        public void SutIsSpecimenBuilder()
        {
            // Arrange
            Func <string, int, decimal, object> dummyFunc = (x, y, z) => new object();
            // Act
            var sut = new SpecimenFactory <string, int, decimal, object>(dummyFunc);

            // Assert
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
        }
 public void FactoryIsCorrect()
 {
     // Fixture setup
     Func<string, int, decimal> expectedFactory = (x, y) => 0m;
     var sut = new SpecimenFactory<string, int, decimal>(expectedFactory);
     // Exercise system
     Func<string, int, decimal> result = sut.Factory;
     // Verify outcome
     Assert.Equal(expectedFactory, result);
     // Teardown
 }
        public void FactoryIsCorrect()
        {
            // Arrange
            Func <int, string> expectedFactory = i => i.ToString();
            var sut = new SpecimenFactory <int, string>(expectedFactory);
            // Act
            Func <int, string> result = sut.Factory;

            // Assert
            Assert.Equal(expectedFactory, result);
        }
 public void FactoryIsCorrect()
 {
     // Fixture setup
     Func<Random, Uri, string, int> expectedFactory = (x, y, z) => 0;
     var sut = new SpecimenFactory<Random, Uri, string, int>(expectedFactory);
     // Exercise system
     Func<Random, Uri, string, int> result = sut.Factory;
     // Verify outcome
     Assert.Equal(expectedFactory, result);
     // Teardown
 }
Example #17
0
        public void FactoryIsCorrect()
        {
            // Arrange
            Func <string, int, decimal> expectedFactory = (x, y) => 0m;
            var sut = new SpecimenFactory <string, int, decimal>(expectedFactory);
            // Act
            Func <string, int, decimal> result = sut.Factory;

            // Assert
            Assert.Equal(expectedFactory, result);
        }
        public void CreateManyOnNullSpecimenBuilderComposerWithSeedAndCountThrows()
        {
            // Fixture setup
            var dummySeed  = new object();
            var dummyCount = 1;

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  SpecimenFactory.CreateMany <object>((ISpecimenBuilderComposer)null, dummySeed, dummyCount));
            // Teardown
        }
Example #19
0
        public void CreateManyOnNullSpecimenBuilderWithCountThrows()
        {
            // Arrange
            var dummyCount = 10;

            // Act & assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  SpecimenFactory.CreateMany <string>(
                                                      (ISpecimenBuilder)null,
                                                      dummyCount));
        }
        public void FactoryIsCorrect()
        {
            // Arrange
            Func <Random, Uri, string, int> expectedFactory = (x, y, z) => 0;
            var sut = new SpecimenFactory <Random, Uri, string, int>(expectedFactory);
            // Act
            Func <Random, Uri, string, int> result = sut.Factory;

            // Assert
            Assert.Equal(expectedFactory, result);
        }
Example #21
0
        public void FactoryIsCorrect()
        {
            // Arrange
            Func <ConcreteType> expectedFactory = () => new ConcreteType(42, "42");
            var sut = new SpecimenFactory <ConcreteType>(expectedFactory);
            // Act
            Func <ConcreteType> result = sut.Factory;

            // Assert
            Assert.Equal(expectedFactory, result);
        }
 public void FactoryIsCorrect()
 {
     // Fixture setup
     Func<LdapStyleUriParser, TimeZone, StringBuilder, DateTime, ConsoleColor> expectedFactory = (x, y, z, æ) => ConsoleColor.Black;
     var sut = new SpecimenFactory<LdapStyleUriParser, TimeZone, StringBuilder, DateTime, ConsoleColor>(expectedFactory);
     // Exercise system
     Func<LdapStyleUriParser, TimeZone, StringBuilder, DateTime, ConsoleColor> result = sut.Factory;
     // Verify outcome
     Assert.Equal(expectedFactory, result);
     // Teardown
 }
        public void FactoryIsCorrect()
        {
            // Arrange
            Func <ConcreteType, TimeZoneInfo, StringBuilder, DateTime, ConsoleColor> expectedFactory = (x, y, z, æ) => ConsoleColor.Black;
            var sut = new SpecimenFactory <ConcreteType, TimeZoneInfo, StringBuilder, DateTime, ConsoleColor>(expectedFactory);
            // Act
            Func <ConcreteType, TimeZoneInfo, StringBuilder, DateTime, ConsoleColor> result = sut.Factory;

            // Assert
            Assert.Equal(expectedFactory, result);
        }
        public void SutIsSpecimenBuilder()
        {
            // Fixture setup
            Func <bool, string, int, decimal, object> dummyFunc = (x, y, z, æ) => new object();
            // Exercise system
            var sut = new SpecimenFactory <bool, string, int, decimal, object>(dummyFunc);

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
            // Teardown
        }
 public void FactoryIsCorrect()
 {
     // Fixture setup
     Func<OperatingSystem> expectedFactory = () => new OperatingSystem(PlatformID.WinCE, new Version(10, 8));
     var sut = new SpecimenFactory<OperatingSystem>(expectedFactory);
     // Exercise system
     Func<OperatingSystem> result = sut.Factory;
     // Verify outcome
     Assert.Equal(expectedFactory, result);
     // Teardown
 }
        public void CreateWithNullContainerThrows()
        {
            // Fixture setup
            var sut          = new SpecimenFactory <object, object, object, object, object>((x, y, z, æ) => x);
            var dummyRequest = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
            // Teardown
        }
 public void FactoryIsCorrect()
 {
     // Fixture setup
     Func<int, string> expectedFactory = i => i.ToString();
     var sut = new SpecimenFactory<int, string>(expectedFactory);
     // Exercise system
     Func<int, string> result = sut.Factory;
     // Verify outcome
     Assert.Equal(expectedFactory, result);
     // Teardown
 }
        public void FactoryIsCorrect()
        {
            // Fixture setup
            Func <string, int, decimal> expectedFactory = (x, y) => 0m;
            var sut = new SpecimenFactory <string, int, decimal>(expectedFactory);
            // Exercise system
            Func <string, int, decimal> result = sut.Factory;

            // Verify outcome
            Assert.Equal(expectedFactory, result);
            // Teardown
        }
        public void FactoryIsCorrect()
        {
            // Fixture setup
            Func <OperatingSystem> expectedFactory = () => new OperatingSystem(PlatformID.WinCE, new Version(10, 8));
            var sut = new SpecimenFactory <OperatingSystem>(expectedFactory);
            // Exercise system
            Func <OperatingSystem> result = sut.Factory;

            // Verify outcome
            Assert.Equal(expectedFactory, result);
            // Teardown
        }
        public void CreateManyOnNullSpecimenBuilderWithCountThrows()
        {
            // Fixture setup
            var dummyCount = 10;

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  SpecimenFactory.CreateMany <string>(
                                                      (ISpecimenBuilder)null,
                                                      dummyCount));
            // Teardown
        }
        public void FactoryIsCorrect()
        {
            // Fixture setup
            Func <Random, Uri, string, int> expectedFactory = (x, y, z) => 0;
            var sut = new SpecimenFactory <Random, Uri, string, int>(expectedFactory);
            // Exercise system
            Func <Random, Uri, string, int> result = sut.Factory;

            // Verify outcome
            Assert.Equal(expectedFactory, result);
            // Teardown
        }
        public void FactoryIsCorrect()
        {
            // Fixture setup
            Func <ConcreteType> expectedFactory = () => new ConcreteType(42, "42");
            var sut = new SpecimenFactory <ConcreteType>(expectedFactory);
            // Exercise system
            Func <ConcreteType> result = sut.Factory;

            // Verify outcome
            Assert.Equal(expectedFactory, result);
            // Teardown
        }
Example #33
0
        public void FactoryIsCorrect()
        {
            // Fixture setup
            Func <int, string> expectedFactory = i => i.ToString();
            var sut = new SpecimenFactory <int, string>(expectedFactory);
            // Exercise system
            Func <int, string> result = sut.Factory;

            // Verify outcome
            Assert.Equal(expectedFactory, result);
            // Teardown
        }
        public void FactoryIsCorrect()
        {
            // Fixture setup
            Func <ConcreteType, TimeZoneInfo, StringBuilder, DateTime, ConsoleColor> expectedFactory = (x, y, z, æ) => ConsoleColor.Black;
            var sut = new SpecimenFactory <ConcreteType, TimeZoneInfo, StringBuilder, DateTime, ConsoleColor>(expectedFactory);
            // Exercise system
            Func <ConcreteType, TimeZoneInfo, StringBuilder, DateTime, ConsoleColor> result = sut.Factory;

            // Verify outcome
            Assert.Equal(expectedFactory, result);
            // Teardown
        }
Example #35
0
 public CaseService()
 {
     specimenRepository  = SpecimenRepository.Instance;
     specimenFactory     = SpecimenFactory.Instance;
     requestorRepository = RequestorRepository.Instance;
     requestorFactory    = RequestorFactory.Instance;
     patientRepository   = PatientRepository.Instance;
     patientFactory      = PatientFactory.Instance;
     caseRepository      = CaseRepository.Instance;
     caseFactory         = CaseFactory.Instance;
     slideFactory        = SlideFactory.Instance;
     slideRepository     = SlideRepository.Instance;
 }
Example #36
0
        public void CreateReturnsCorrectResult()
        {
            // Arrange
            var           expectedSpecimen = new object();
            Func <object> creator          = () => expectedSpecimen;
            var           sut = new SpecimenFactory <object>(creator);
            // Act
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(dummyRequest, dummyContainer);

            // Assert
            Assert.Equal(expectedSpecimen, result);
        }
 public void CreateReturnsCorrectResult()
 {
     // Fixture setup
     var expectedSpecimen = new object();
     Func<object> creator = () => expectedSpecimen;
     var sut = new SpecimenFactory<object>(creator);
     // Exercise system
     var dummyRequest = new object();
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(dummyRequest, dummyContainer);
     // Verify outcome
     Assert.Equal(expectedSpecimen, result);
     // Teardown
 }
        public void CreateReturnsCorrectResult()
        {
            // Fixture setup
            var           expectedSpecimen = new object();
            Func <object> creator          = () => expectedSpecimen;
            var           sut = new SpecimenFactory <object>(creator);
            // Exercise system
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(dummyRequest, dummyContainer);

            // Verify outcome
            Assert.Equal(expectedSpecimen, result);
            // Teardown
        }
        public void FromTripleArgFuncReturnsCorrectResult()
        {
            // Arrange
            var sut = SpecimenBuilderNodeFactory.CreateComposer <decimal>();
            Func <int, Guid, Version, decimal> f = (i, g, v) => i;
            // Act
            var actual = sut.FromFactory(f);
            // Assert
            var factory  = new SpecimenFactory <int, Guid, Version, decimal>(f);
            var expected = new NodeComposer <decimal>(
                SpecimenBuilderNodeFactory.CreateTypedNode(typeof(decimal), factory));

            var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual);

            Assert.True(expected.GraphEquals(n, new NodeComparer()));
        }
        public void FromQuadrupleArgFuncReturnsCorrectResult()
        {
            // Arrange
            var sut = SpecimenBuilderNodeFactory.CreateComposer <Version>();
            Func <int, int, int, int, Version> f = (mj, mn, b, r) => new Version(mj, mn, b, r);
            // Act
            var actual = sut.FromFactory(f);
            // Assert
            var factory  = new SpecimenFactory <int, int, int, int, Version>(f);
            var expected = new NodeComposer <Version>(
                SpecimenBuilderNodeFactory.CreateTypedNode(typeof(Version), factory));

            var n = Assert.IsAssignableFrom <ISpecimenBuilderNode>(actual);

            Assert.True(expected.GraphEquals(n, new NodeComparer()));
        }
        public void CreateWillReturnCorrectResult()
        {
            // Fixture setup
            var expectedSpecimen = new object();

            var dtSpecimen = DateTimeOffset.Now;
            var expectedParameterRequest = typeof(DateTimeOffset);
            var container = new DelegatingSpecimenContext { OnResolve = r => expectedParameterRequest.Equals(r) ? (object)dtSpecimen : new NoSpecimen(r) };

            Func<DateTimeOffset, object> f = dt => dtSpecimen.Equals(dt) ? expectedSpecimen : new NoSpecimen(dt);
            var sut = new SpecimenFactory<DateTimeOffset, object>(f);
            // Exercise system
            var dummyRequest = new object();
            var result = sut.Create(dummyRequest, container);
            // Verify outcome
            Assert.Equal(expectedSpecimen, result);
            // Teardown
        }
Example #42
0
        public void FromNoArgFuncReturnsCorrectResult()
        {
            // Fixture setup
            var sut = SpecimenBuilderNodeFactory.CreateComposer<long>();
            Func<long> f = () => 0;
            // Exercise system
            var actual = sut.FromFactory(f);
            // Verify outcome
            var factory = new SpecimenFactory<long>(f);
            var expected = new NodeComposer<long>(
                SpecimenBuilderNodeFactory.CreateTypedNode(typeof(long), factory));

            var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual);
            Assert.True(expected.GraphEquals(n, new NodeComparer()));
            // Teardown
        }
Example #43
0
        public void FromTripleArgFuncReturnsCorrectResult()
        {
            // Fixture setup
            var sut = SpecimenBuilderNodeFactory.CreateComposer<decimal>();
            Func<int, Guid, Version, decimal> f = (i, g, v) => i;
            // Exercise system
            var actual = sut.FromFactory(f);
            // Verify outcome
            var factory = new SpecimenFactory<int, Guid, Version, decimal>(f);
            var expected = new NodeComposer<decimal>(
                SpecimenBuilderNodeFactory.CreateTypedNode(typeof(decimal), factory));

            var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual);
            Assert.True(expected.GraphEquals(n, new NodeComparer()));
            // Teardown
        }
Example #44
0
        public void FromQuadrupleArgFuncReturnsCorrectResult()
        {
            // Fixture setup
            var sut = SpecimenBuilderNodeFactory.CreateComposer<Version>();
            Func<int, int, int, int, Version> f = (mj, mn, b, r) => new Version(mj, mn, b, r);
            // Exercise system
            var actual = sut.FromFactory(f);
            // Verify outcome
            var factory = new SpecimenFactory<int, int, int, int, Version>(f);
            var expected = new NodeComposer<Version>(
                SpecimenBuilderNodeFactory.CreateTypedNode(typeof(Version), factory));

            var n = Assert.IsAssignableFrom<ISpecimenBuilderNode>(actual);
            Assert.True(expected.GraphEquals(n, new NodeComparer()));
            // Teardown
        }