コード例 #1
0
        public void New_ShouldReturnUniqueIdentifiers()
        {
            // Arrange.
            var target = (EnhancedReadabilityGuid[])null;

            // Act.
            target = new EnhancedReadabilityGuid[]
            {
                EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New(),
                    EnhancedReadabilityGuid.New()
            };

            // Assert.
            target.Should().OnlyHaveUniqueItems();
        }
コード例 #2
0
        public void EqualityComparer_ShouldReturnValidResult()
        {
            // Arrange.
            var valueOne    = Guid.Parse("4aaadf09-0a66-41dc-bfc8-f8520f4aeaf8");
            var valueTwo    = Guid.Parse("5645c7ea-4729-4443-a41c-1c22dd0e61a7");
            var targetOne   = new EnhancedReadabilityGuid(valueOne);
            var targetTwo   = new EnhancedReadabilityGuid(valueOne);
            var targetThree = new EnhancedReadabilityGuid(valueTwo);

            // Act.
            var resultOne   = targetOne.Equals(targetTwo);
            var resultTwo   = targetTwo.Equals(targetThree);
            var resultThree = targetTwo == targetOne;
            var resultFour  = targetThree == targetOne;
            var resultFive  = targetOne != targetThree;
            var resultSix   = targetTwo != targetOne;

            // Assert.
            resultOne.Should().BeTrue();
            resultTwo.Should().BeFalse();
            resultThree.Should().BeTrue();
            resultFour.Should().BeFalse();
            resultFive.Should().BeTrue();
            resultSix.Should().BeFalse();
        }
コード例 #3
0
        public void FunctionalLifeSpanTest_ShouldProduceDesiredResults()
        {
            // Arrange.
            var package              = new SimulatedAutofacDependencyPackage();
            var databaseName         = EnhancedReadabilityGuid.New().ToString();
            var configurationBuilder = new ConfigurationBuilder();
            var configuration        = configurationBuilder.Build();
            var scope                       = (IDependencyScope)null;
            var commandMediator             = (ICommandMediator)null;
            var command                     = new GetFibonacciNumberValuesCommand();
            var fibonacciNumberSeriesValues = new Int64[] { 0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };

            using (var engine = package.CreateEngine(configuration))
            {
                // Arrange.
                scope           = engine.Container.CreateScope();
                commandMediator = scope.Resolve <ICommandMediator>();

                using (var context = new PrototypeInMemoryContext(configuration, databaseName).WithTestData())
                {
                    using (var repositoryFactory = new PrototypeRepositoryFactory(configuration, context))
                    {
                        using (var commandHandler = new GetFibonacciNumberValuesCommandHandler(commandMediator, repositoryFactory))
                        {
                            // Act.
                            var result = commandHandler.Process(command);

                            // Assert.
                            result.Should().BeEquivalentTo(fibonacciNumberSeriesValues);
                        }
                    }
                }
            }
        }
コード例 #4
0
        public void ImplicitCastOperator_ShouldProduceDesiredResults()
        {
            // Arrange.
            var value  = Guid.Parse("4aaadf09-0a66-41dc-bfc8-f8520f4aeaf8");
            var target = new EnhancedReadabilityGuid(value);

            // Assert.
            value.Should().Be(target);
        }
コード例 #5
0
        public void ToGuid_ShouldReturnValidResult()
        {
            // Arrange.
            var target = EnhancedReadabilityGuid.Parse("jazikf3ckyzdw9n3azw6yfj7a8");

            // Act.
            var result = target.ToGuid();

            // Assert.
            result.Should().Be(Guid.Parse("4aaadf09-0a66-41dc-bfc8-f8520f4aeaf8"));
        }
コード例 #6
0
        public void Parse_ShouldReturnValidResult()
        {
            // Arrange.
            var value  = Guid.Parse("4aaadf09-0a66-41dc-bfc8-f8520f4aeaf8");
            var target = new EnhancedReadabilityGuid(value);

            // Act.
            var result = EnhancedReadabilityGuid.Parse(target.ToString());

            // Assert.
            result.Should().Be(target);
        }
コード例 #7
0
        public void TryParse_ShouldReturnValidResult_ForValidShortIdentifierString_AsUppercaseString()
        {
            // Arrange.
            var value  = Guid.Parse("4aaadf09-0a66-41dc-bfc8-f8520f4aeaf8");
            var target = new EnhancedReadabilityGuid(value);

            // Act.
            var resultTwo = EnhancedReadabilityGuid.TryParse(target.ToString().ToUpper(), out var resultOne);

            // Assert.
            resultOne.Should().Be(target);
            resultTwo.Should().BeTrue();
        }
コード例 #8
0
        public void ToByteArray_ShouldReturnValidResult()
        {
            // Arrange.
            var value  = Guid.Parse("4aaadf09-0a66-41dc-bfc8-f8520f4aeaf8");
            var target = new EnhancedReadabilityGuid(value);

            // Act.
            var result = target.ToByteArray();

            // Assert.
            result.Should().NotBeNull();
            result.Length.Should().Be(16);
        }
コード例 #9
0
        private static void ShouldBeSerializable(SerializationFormat format)
        {
            // Arrange. Arrange.
            var value      = Guid.Parse("4aaadf09-0a66-41dc-bfc8-f8520f4aeaf8");
            var identifier = new EnhancedReadabilityGuid(value);
            var target     = new EnhancedReadabilityGuidContainer(identifier);
            var serializer = new DynamicSerializer <EnhancedReadabilityGuidContainer>(format);

            // Act.
            var serializedTarget   = serializer.Serialize(target);
            var deserializedResult = serializer.Deserialize(serializedTarget);

            // Assert.
            deserializedResult.Identifier.Should().Be(identifier);
        }
コード例 #10
0
        public void FunctionalLifeSpanTest_ShouldProduceDesiredResults()
        {
            // Arrange.
            var databaseName                = EnhancedReadabilityGuid.New().ToString();
            var configuration               = new ConfigurationBuilder().Build();
            var fibonacciNumberSeriesName   = "Fibonacci";
            var fibonacciNumberSeriesValues = new Int64[] { 0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 };

            using (var context = new PrototypeInMemoryContext(configuration, databaseName).WithTestData())
            {
                using (var numberSeriesRepository = new NumberSeriesRepository(context))
                {
                    // Act.
                    var fibonacciNumberSeries = numberSeriesRepository.FindByName(fibonacciNumberSeriesName);

                    // Assert.
                    fibonacciNumberSeries.Should().NotBeNull();
                    fibonacciNumberSeries.Name.Should().Be(fibonacciNumberSeriesName);

                    using (var numberSeriesNumberRepository = new NumberSeriesNumberRepository(context))
                    {
                        // Act.
                        var fibonacciNumberSeriesNumbers = numberSeriesNumberRepository.FindWhere(entity => entity.NumberSeriesIdentifier == fibonacciNumberSeries.Identifier);
                        var fibonacciNumberIdentifiers   = fibonacciNumberSeriesNumbers.Select(entity => entity.NumberIdentifier);

                        // Assert.
                        fibonacciNumberSeriesNumbers.Should().NotBeNull();
                        fibonacciNumberSeriesNumbers.Count().Should().Be(fibonacciNumberSeriesValues.Length);

                        using (var numberRepository = new NumberRepository(context))
                        {
                            // Act.
                            var fibonacciNumbers = numberRepository.FindWhere(entity => fibonacciNumberIdentifiers.Contains(entity.Identifier)).OrderBy(entity => entity.Value);

                            // Assert.
                            fibonacciNumbers.Select(entity => entity.Value).Should().BeEquivalentTo(fibonacciNumberSeriesValues);
                        }
                    }
                }
            }
        }
コード例 #11
0
 public EnhancedReadabilityGuidContainer(EnhancedReadabilityGuid identifier)
 {
     Identifier = identifier;
 }
コード例 #12
0
 internal static String GetSubscriptionName <TMessage>()
     where TMessage : class => $"Subscription-{EnhancedReadabilityGuid.New().ToString()}";