コード例 #1
0
        private void updateReporeters()
        {
            _reporters = new List <TypeRepresentation>();
            TypeRepresentation nullType = new TypeRepresentation();

            nullType.Count = Base.Implementations.MessageHub.Reporters.Count();
            _reporters.Add(nullType);
            foreach (Base.Interfaces.IReportMessage r in Base.Implementations.MessageHub.Reporters)
            {
                TypeRepresentation newTr = new TypeRepresentation(r);
                bool hasMatch            = false;
                foreach (TypeRepresentation tr in _reporters)
                {
                    if (tr.Assembly == newTr.Assembly)
                    {
                        hasMatch = true;
                        tr.Count++;
                    }
                }
                if (!hasMatch)
                {
                    _reporters.Add(new TypeRepresentation(r));
                }
            }
            if (_reporters.Count() > 0)
            {
                Sender = _reporters.First();
            }
            NotifyPropertyChanged(nameof(Reporters));
        }
        public static void ResolvedFromLoadedTypes_typeRepresentation___Should_throw_InvalidOperationException___When_assembly_is_not_loaded_prior_to_call_and_cannot_be_loaded_by_call_and_throwIfCannotResolve_is_true()
        {
            // Arrange
            var dummyAssembly = A.Dummy <string>();

            var representation1 = A.Dummy <TypeRepresentation>().DeepCloneWithAssemblyName(dummyAssembly);

            var representation2 = A.Dummy <TypeRepresentation>().Whose(_ => _.IsClosedGenericType());

            var modifiedGenericArgument = representation2.GenericArguments.First().DeepCloneWithAssemblyName(dummyAssembly);

            var modifiedGenericArguments = new TypeRepresentation[0].Concat(new[] { modifiedGenericArgument }).Concat(representation2.GenericArguments.Skip(1)).ToList();

            representation2 = representation2.DeepCloneWithGenericArguments(modifiedGenericArguments);

            // Act
            var actual1 = Record.Exception(() => representation1.ResolveFromLoadedTypes(AssemblyMatchStrategy.AnySingleVersion, throwIfCannotResolve: true));
            var actual2 = Record.Exception(() => representation2.ResolveFromLoadedTypes(AssemblyMatchStrategy.AnySingleVersion, throwIfCannotResolve: true));

            // Assert
            actual1.AsTest().Must().BeOfType <InvalidOperationException>();
            actual1.Message.AsTest().Must().ContainString("Unable to resolve the specified TypeRepresentation");
            actual1.Message.AsTest().Must().ContainString("These assemblies are not loaded: " + dummyAssembly);

            actual2.AsTest().Must().BeOfType <InvalidOperationException>();
            actual2.Message.AsTest().Must().ContainString("Unable to resolve the specified TypeRepresentation");
            actual2.Message.AsTest().Must().ContainString("These assemblies are not loaded: " + dummyAssembly);
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogItemContext"/> class.
        /// </summary>
        /// <param name="timestampUtc">The date/time, in UTC, when the log-item was logged.</param>
        /// <param name="origin">The origin of the log-item.</param>
        /// <param name="machineName">Optional name of the machine that generated the log-item.</param>
        /// <param name="processName">Optional name of the process that generated the log-item.</param>
        /// <param name="processFileVersion">Optional file version of the process that generated the log-item.</param>
        /// <param name="callingMethod">Optional calling method.</param>
        /// <param name="callingType">Optional description of the calling type.</param>
        /// <param name="stackTrace">Optional stack trace.</param>
        public LogItemContext(
            DateTime timestampUtc,
            string origin,
            string machineName             = null,
            string processName             = null,
            string processFileVersion      = null,
            string callingMethod           = null,
            TypeRepresentation callingType = null,
            string stackTrace = null)
        {
            if (timestampUtc.Kind != DateTimeKind.Utc)
            {
                throw new ArgumentException(Invariant($"{nameof(timestampUtc)}.{nameof(DateTime.Kind)} != {nameof(DateTimeKind)}.{nameof(DateTimeKind.Utc)}"));
            }

            if (string.IsNullOrWhiteSpace(origin))
            {
                throw new ArgumentException(Invariant($"{nameof(origin)} cannot be null or whitespace."));
            }

            this.TimestampUtc       = timestampUtc;
            this.Origin             = origin;
            this.MachineName        = machineName;
            this.ProcessName        = processName;
            this.ProcessFileVersion = processFileVersion;
            this.CallingMethod      = callingMethod;
            this.CallingType        = callingType;
            this.StackTrace         = stackTrace;
        }
コード例 #4
0
        public RunScheduleOp DeepCloneWithDeprecatedIdentifierType(TypeRepresentation deprecatedIdentifierType)
        {
            var result = new RunScheduleOp(
                deprecatedIdentifierType);

            return(result);
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RunReactorOp"/> class.
 /// </summary>
 /// <param name="degreesOfParallelismForDependencyChecks">The ideal number of <see cref="ReactionRegistration"/>'s to evaluate in parallel; used in <see cref="ParallelOptions"/> for 'MaxDegreeOfParallelism', see documentation for restrictions.</param>
 /// <param name="deprecatedIdentifierType">OPTIONAL type to consider as a deprecated identifier (e.g. <see cref="T:Naos.Database.Domain.IdDeprecatedEvent" />).  DEFAULT is none.</param>
 public RunReactorOp(
     int degreesOfParallelismForDependencyChecks = -1,
     TypeRepresentation deprecatedIdentifierType = null)
 {
     this.DegreesOfParallelismForDependencyChecks = degreesOfParallelismForDependencyChecks;
     this.DeprecatedIdentifierType = deprecatedIdentifierType;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StringDescribedSerialization"/> class.
 /// </summary>
 /// <param name="payloadTypeRepresentation">The type of object serialized.</param>
 /// <param name="serializerRepresentation">The serializer used to generate the payload.</param>
 /// <param name="serializedPayload">The serialized payload.</param>
 public StringDescribedSerialization(
     TypeRepresentation payloadTypeRepresentation,
     SerializerRepresentation serializerRepresentation,
     string serializedPayload)
     : base(payloadTypeRepresentation, serializerRepresentation)
 {
     this.SerializedPayload = serializedPayload;
 }
コード例 #7
0
        public RunReactorOp DeepCloneWithDeprecatedIdentifierType(TypeRepresentation deprecatedIdentifierType)
        {
            var result = new RunReactorOp(
                this.DegreesOfParallelismForDependencyChecks.DeepClone(),
                deprecatedIdentifierType);

            return(result);
        }
コード例 #8
0
        public GetProtocolByTypeOp DeepCloneWithProtocolType(TypeRepresentation protocolType)
        {
            var result = new GetProtocolByTypeOp(
                protocolType,
                this.MissingProtocolStrategy.DeepClone());

            return(result);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BinaryDescribedSerialization"/> class.
 /// </summary>
 /// <param name="payloadTypeRepresentation">The type of object serialized.</param>
 /// <param name="serializerRepresentation">The serializer used to generate the payload.</param>
 /// <param name="serializedPayload">The serialized payload.</param>
 public BinaryDescribedSerialization(
     TypeRepresentation payloadTypeRepresentation,
     SerializerRepresentation serializerRepresentation,
     byte[] serializedPayload)
     : base(payloadTypeRepresentation, serializerRepresentation)
 {
     this.SerializedPayload = serializedPayload;
 }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DescribedSerialization"/> class.
        /// </summary>
        /// <param name="payloadTypeRepresentation">A description of the type of object serialized.</param>
        /// <param name="serializedPayload">The object serialized to a string.</param>
        /// <param name="serializationDescription">The serializer used to generate the payload.</param>
        /// <exception cref="ArgumentNullException"><paramref name="payloadTypeRepresentation"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="serializedPayload"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="serializedPayload"/> is whitespace.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="serializationDescription"/> is null.</exception>
        /// <exception cref="ArgumentException"><paramref name="serializationDescription"/> is whitespace.</exception>
        public DescribedSerialization(TypeRepresentation payloadTypeRepresentation, string serializedPayload, SerializationDescription serializationDescription)
        {
            new { payloadTypeRepresentation }.Must().NotBeNull();
            new { serializationDescription }.Must().NotBeNull();

            this.PayloadTypeRepresentation = payloadTypeRepresentation;
            this.SerializedPayload         = serializedPayload;
            this.SerializationDescription  = serializationDescription;
        }
        public ChannelOperationMonitoringInfo DeepCloneWithFailedEventType(TypeRepresentation failedEventType)
        {
            var result = new ChannelOperationMonitoringInfo(
                this.ChannelOperationTrackingCodeId.DeepClone(),
                this.SucceededEventType?.DeepClone(),
                failedEventType);

            return(result);
        }
        public ChannelOperationOutcomeInfo DeepCloneWithEventType(TypeRepresentation eventType)
        {
            var result = new ChannelOperationOutcomeInfo(
                this.ChannelOperationTrackingCodeId.DeepClone(),
                eventType,
                this.Outcome.DeepClone());

            return(result);
        }
        public static TypeRepresentation ChangeVersion(
            TypeRepresentation representation,
            string newVersion)
        {
            var result = representation.DeepCloneWithAssemblyVersion(newVersion);

            result = result.DeepCloneWithGenericArguments(result.GenericArguments?.Select(_ => ChangeVersion(_, newVersion)).ToList());

            return(result);
        }
コード例 #14
0
        public SerializerRepresentation DeepCloneWithSerializationConfigType(TypeRepresentation serializationConfigType)
        {
            var result = new SerializerRepresentation(
                this.SerializationKind.DeepClone(),
                serializationConfigType,
                this.CompressionKind.DeepClone(),
                this.Metadata?.DeepClone());

            return(result);
        }
コード例 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChannelOperationOutcomeInfo"/> class.
        /// </summary>
        /// <param name="channelOperationTrackingCodeId">The tracking code identifier for the channel operation.</param>
        /// <param name="eventType">The type of event that specified the outcome.</param>
        /// <param name="outcome">The outcome of executing the operation.</param>
        public ChannelOperationOutcomeInfo(
            long channelOperationTrackingCodeId,
            TypeRepresentation eventType,
            ChannelOperationOutcome outcome)
        {
            new { eventType }.AsArg().Must().NotBeNull();
            new { outcome }.AsArg().Must().NotBeEqualTo(ChannelOperationOutcome.Unknown);

            this.ChannelOperationTrackingCodeId = channelOperationTrackingCodeId;
            this.EventType = eventType;
            this.Outcome   = outcome;
        }
コード例 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChannelOperationMonitoringInfo"/> class.
        /// </summary>
        /// <param name="channelOperationTrackingCodeId">The tracking code identifier for the channel operation.</param>
        /// <param name="succeededEventType">The event type that indicates that the operation succeeded.</param>
        /// <param name="failedEventType">The event type that indicates that the operation failed.</param>
        public ChannelOperationMonitoringInfo(
            long channelOperationTrackingCodeId,
            TypeRepresentation succeededEventType,
            TypeRepresentation failedEventType)
        {
            new { succeededEventType }.AsArg().Must().NotBeNull();
            new { failedEventType }.AsArg().Must().NotBeNull().And().NotBeEqualTo(succeededEventType);

            this.ChannelOperationTrackingCodeId = channelOperationTrackingCodeId;
            this.SucceededEventType             = succeededEventType;
            this.FailedEventType = failedEventType;
        }
        public static void RemoveAssemblyVersions___Should_remove_assembly_version_for_all_contained_types___When_called()
        {
            // Arrange
            var stringType = typeof(string);

            var intType = typeof(int);

            var collectionType = typeof(IReadOnlyCollection <string> [, ]);

            var dictionaryType = typeof(Dictionary <string, int>);

            var collectionOfCollectionType = typeof(IReadOnlyCollection <Dictionary <string, int> > [, ]);

            var dictionaryGenericTypeDefinition = dictionaryType.GetGenericTypeDefinition();

            var representation1 = stringType.ToRepresentation();

            var representation2 = collectionType.ToRepresentation();

            var representation3 = collectionOfCollectionType.ToRepresentation();

            var representation4 = dictionaryGenericTypeDefinition.ToRepresentation();

            var expected1 = new TypeRepresentation(stringType.Namespace, stringType.Name, stringType.Assembly.GetName().Name, null, null);

            var expected2 = new TypeRepresentation(collectionType.Namespace, collectionType.Name, collectionType.Assembly.GetName().Name, null, new[] { expected1 });

            var expected3 = new TypeRepresentation(collectionType.Namespace, collectionType.Name, collectionType.Assembly.GetName().Name, null, new[]
            {
                new TypeRepresentation(dictionaryType.Namespace, dictionaryType.Name, dictionaryType.Assembly.GetName().Name, null, new[]
                {
                    new TypeRepresentation(stringType.Namespace, stringType.Name, stringType.Assembly.GetName().Name, null, null),
                    new TypeRepresentation(intType.Namespace, intType.Name, intType.Assembly.GetName().Name, null, null),
                }),
            });

            var expected4 = new TypeRepresentation(dictionaryGenericTypeDefinition.Namespace, dictionaryGenericTypeDefinition.Name, dictionaryGenericTypeDefinition.Assembly.GetName().Name, null, new TypeRepresentation[] { });

            // Act
            var actual1  = representation1.RemoveAssemblyVersions();
            var actual2a = representation2.RemoveAssemblyVersions();
            var actual2b = actual2a.RemoveAssemblyVersions();
            var actual3  = representation3.RemoveAssemblyVersions();
            var actual4  = representation4.RemoveAssemblyVersions();

            // Assert
            actual1.AsTest().Must().BeEqualTo(expected1);
            actual2a.AsTest().Must().BeEqualTo(expected2);
            actual2b.AsTest().Must().BeEqualTo(expected2);
            actual3.AsTest().Must().BeEqualTo(expected3);
            actual4.AsTest().Must().BeEqualTo(expected4);
        }
コード例 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DescribedSerializationBase"/> class.
        /// </summary>
        /// <param name="payloadTypeRepresentation">The type of object serialized.</param>
        /// <param name="serializerRepresentation">The serializer used to generate the payload.</param>
        protected DescribedSerializationBase(
            TypeRepresentation payloadTypeRepresentation,
            SerializerRepresentation serializerRepresentation)
        {
            if (payloadTypeRepresentation == null)
            {
                throw new ArgumentNullException(nameof(payloadTypeRepresentation));
            }

            if (serializerRepresentation == null)
            {
                throw new ArgumentNullException(nameof(serializerRepresentation));
            }

            this.PayloadTypeRepresentation = payloadTypeRepresentation;
            this.SerializerRepresentation  = serializerRepresentation;
        }
        public static void BuildAssemblyQualifiedName___Should_build_assembly_qualified___When_TypeRepresentation_contains_a_mix_of_versioned_and_unversioned_types()
        {
            // Arrange
            var intRepresentation = new TypeRepresentation("System", "Int32", "ass1", "1.0.0.0", null);

            var stringRepresentation = new TypeRepresentation("System", "String", "ass2", "2.0.0.0", null);

            var guidRepresentation = new TypeRepresentation("System", "Guid", "ass3", null, null);

            var dictionaryRepresentation = new TypeRepresentation("System", "IReadOnlyDictionary`2", "ass4", "3.0.0.0", new[] { stringRepresentation, guidRepresentation });

            var systemUnderTest = new TypeRepresentation("System", "Dictionary`2", "ass5", null, new[] { dictionaryRepresentation, intRepresentation });

            // Act
            var actual = systemUnderTest.BuildAssemblyQualifiedName();

            // Assert
            actual.AsTest().Must().BeEqualTo("System.Dictionary`2[[System.IReadOnlyDictionary`2[[System.String, ass2, Version=2.0.0.0],[System.Guid, ass3]], ass4, Version=3.0.0.0],[System.Int32, ass1, Version=1.0.0.0]], ass5");
        }
        public static void ResolvedFromLoadedTypes_typeRepresentation___Should_return_null___When_assembly_is_not_loaded_prior_to_call_and_cannot_be_loaded_by_call_and_throwIfCannotResolve_is_false()
        {
            // Arrange
            var representation1 = A.Dummy <TypeRepresentation>().DeepCloneWithAssemblyName(A.Dummy <string>());

            var representation2 = A.Dummy <TypeRepresentation>().Whose(_ => _.IsClosedGenericType());

            var modifiedGenericArgument = representation2.GenericArguments.First().DeepCloneWithAssemblyName(A.Dummy <string>());

            var modifiedGenericArguments = new TypeRepresentation[0].Concat(new[] { modifiedGenericArgument }).Concat(representation2.GenericArguments.Skip(1)).ToList();

            representation2 = representation2.DeepCloneWithGenericArguments(modifiedGenericArguments);

            // Act
            var actual1 = representation1.ResolveFromLoadedTypes(AssemblyMatchStrategy.AnySingleVersion, throwIfCannotResolve: false);
            var actual2 = representation2.ResolveFromLoadedTypes(AssemblyMatchStrategy.AnySingleVersion, throwIfCannotResolve: false);

            // Assert
            actual1.AsTest().Must().BeNull();
            actual2.AsTest().Must().BeNull();
        }
コード例 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializerRepresentation"/> class.
        /// </summary>
        /// <param name="serializationKind">The <see cref="SerializationKind" /> to serialize into.</param>
        /// <param name="compressionKind">Optional <see cref="CompressionKind" /> to use; DEFAULT is None.</param>
        /// <param name="serializationConfigType">Optional representation of the type of the serialization configuration to use; DEFAULT is null.</param>
        /// <param name="metadata">Optional metadata to put, especially useful for custom serializer factory; DEFAULT is empty.</param>
        public SerializerRepresentation(
            SerializationKind serializationKind,
            TypeRepresentation serializationConfigType    = null,
            CompressionKind compressionKind               = CompressionKind.None,
            IReadOnlyDictionary <string, string> metadata = null)
        {
            if (serializationKind == SerializationKind.Invalid)
            {
                throw new ArgumentOutOfRangeException(Invariant($"'{nameof(serializationKind)}' == '{SerializationKind.Invalid}'"), (Exception)null);
            }

            if (compressionKind == CompressionKind.Invalid)
            {
                throw new ArgumentOutOfRangeException(Invariant($"'{nameof(compressionKind)}' == '{CompressionKind.Invalid}'"), (Exception)null);
            }

            this.SerializationKind       = serializationKind;
            this.SerializationConfigType = serializationConfigType;
            this.CompressionKind         = compressionKind;
            this.Metadata = metadata ?? new Dictionary <string, string>();
        }
コード例 #22
0
ファイル: ParameterRepresentation.cs プロジェクト: 210342/TPA
 public ParameterRepresentation(TypeRepresentation type, string methodName, ParameterInfo parameter)
 {
     Name     = parameter.Name;
     FullName = ExpectedFullName(methodName, parameter);
     Type     = type;
 }
コード例 #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializationDescription"/> class.
        /// </summary>
        /// <param name="serializationKind">The <see cref="SerializationKind" /> to serialize into.</param>
        /// <param name="serializationFormat">The <see cref="SerializationFormat" /> to serialize into.</param>
        /// <param name="compressionKind">Optional <see cref="CompressionKind" /> to use; DEFAULT is None.</param>
        /// <param name="configurationTypeRepresentation">Optional configuration to use; DEFAULT is null.</param>
        /// <param name="metadata">Optional metadata to put, especially useful for customer serializer factory; DEFAULT is empty.</param>
        public SerializationDescription(SerializationKind serializationKind, SerializationFormat serializationFormat, TypeRepresentation configurationTypeRepresentation = null, CompressionKind compressionKind = CompressionKind.None, IReadOnlyDictionary <string, string> metadata = null)
        {
            new { serializationKind }.Must().NotBeEqualTo(SerializationKind.Invalid);
            new { serializationFormat }.Must().NotBeEqualTo(SerializationFormat.Invalid);
            new { compressionKind }.Must().NotBeEqualTo(CompressionKind.Invalid);

            this.SerializationKind               = serializationKind;
            this.SerializationFormat             = serializationFormat;
            this.ConfigurationTypeRepresentation = configurationTypeRepresentation;
            this.CompressionKind = compressionKind;
            this.Metadata        = metadata ?? new Dictionary <string, string>();
        }
        static TypeRepresentationTest()
        {
            ConstructorArgumentValidationTestScenarios
            .RemoveAllScenarios()
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentNullException when parameter 'namespace' is null scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new TypeRepresentation(
                        null,
                        referenceObject.Name,
                        referenceObject.AssemblyName,
                        referenceObject.AssemblyVersion,
                        referenceObject.GenericArguments);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentNullException),
                ExpectedExceptionMessageContains = new[] { "namespace" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentException when parameter 'namespace' is white space scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new TypeRepresentation(
                        Invariant($"  {Environment.NewLine}  "),
                        referenceObject.Name,
                        referenceObject.AssemblyName,
                        referenceObject.AssemblyVersion,
                        referenceObject.GenericArguments);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "namespace", "white space" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentNullException when parameter 'name' is null scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new TypeRepresentation(
                        referenceObject.Namespace,
                        null,
                        referenceObject.AssemblyName,
                        referenceObject.AssemblyVersion,
                        referenceObject.GenericArguments);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentNullException),
                ExpectedExceptionMessageContains = new[] { "name" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentException when parameter 'name' is white space scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new TypeRepresentation(
                        referenceObject.Namespace,
                        Invariant($"  {Environment.NewLine}  "),
                        referenceObject.AssemblyName,
                        referenceObject.AssemblyVersion,
                        referenceObject.GenericArguments);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "name", "white space" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentNullException when parameter 'assemblyName' is null scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new TypeRepresentation(
                        referenceObject.Namespace,
                        referenceObject.Name,
                        null,
                        referenceObject.AssemblyVersion,
                        referenceObject.GenericArguments);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentNullException),
                ExpectedExceptionMessageContains = new[] { "assemblyName" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentException when parameter 'assemblyName' is white space scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new TypeRepresentation(
                        referenceObject.Namespace,
                        referenceObject.Name,
                        Invariant($"  {Environment.NewLine}  "),
                        referenceObject.AssemblyVersion,
                        referenceObject.GenericArguments);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "assemblyName", "white space" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentException when parameter 'assemblyVersion' is white space scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new TypeRepresentation(
                        referenceObject.Namespace,
                        referenceObject.Name,
                        referenceObject.AssemblyName,
                        Invariant($"  {Environment.NewLine}  "),
                        referenceObject.GenericArguments);

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "assemblyVersion", "white space" },
            })
            .AddScenario(() =>
                         new ConstructorArgumentValidationTestScenario <TypeRepresentation>
            {
                Name             = "constructor should throw ArgumentException when parameter 'genericArguments' contains a null element scenario",
                ConstructionFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>().ThatIs(_ => _.IsClosedGenericType());

                    var result = new TypeRepresentation(
                        referenceObject.Namespace,
                        referenceObject.Name,
                        referenceObject.AssemblyName,
                        referenceObject.AssemblyVersion,
                        new TypeRepresentation[0].Concat(referenceObject.GenericArguments).Concat(new TypeRepresentation[] { null }).Concat(referenceObject.GenericArguments).ToList());

                    return(result);
                },
                ExpectedExceptionType            = typeof(ArgumentException),
                ExpectedExceptionMessageContains = new[] { "genericArguments", "contains at least one null element" },
            });

            ConstructorPropertyAssignmentTestScenarios
            .AddScenario(() =>
                         new ConstructorPropertyAssignmentTestScenario <TypeRepresentation>
            {
                Name = "GenericArguments should return null, when 'genericArguments' parameter passed to constructor is null, when getting",
                SystemUnderTestExpectedPropertyValueFunc = () =>
                {
                    var referenceObject = A.Dummy <TypeRepresentation>();

                    var result = new SystemUnderTestExpectedPropertyValue <TypeRepresentation>
                    {
                        SystemUnderTest = new TypeRepresentation(
                            referenceObject.Namespace,
                            referenceObject.Name,
                            referenceObject.AssemblyName,
                            referenceObject.AssemblyVersion,
                            null),
                        ExpectedPropertyValue = null,
                    };

                    return(result);
                },
                PropertyName = "GenericArguments",
            });

            StringRepresentationTestScenarios
            .AddScenario(() =>
                         new StringRepresentationTestScenario <TypeRepresentation>
            {
                Name = "ToString should return the same string as BuildAssemblyQualifiedName() when called",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                {
                    var systemUnderTest = A.Dummy <TypeRepresentation>();

                    var result = new SystemUnderTestExpectedStringRepresentation <TypeRepresentation>
                    {
                        SystemUnderTest = systemUnderTest,
                        ExpectedStringRepresentation = systemUnderTest.BuildAssemblyQualifiedName(),
                    };

                    return(result);
                },
            })
            .AddScenario(() =>
                         new StringRepresentationTestScenario <TypeRepresentation>
            {
                Name = "ToString should return the Assembly Qualified Name when called",
                SystemUnderTestExpectedStringRepresentationFunc = () =>
                {
                    var systemUnderTest = typeof(IReadOnlyCollection <string> [, ]).ToRepresentation();

                    var result = new SystemUnderTestExpectedStringRepresentation <TypeRepresentation>
                    {
                        SystemUnderTest = systemUnderTest,
                        ExpectedStringRepresentation = "System.Collections.Generic.IReadOnlyCollection`1[[System.String, mscorlib, Version=4.0.0.0]][,], mscorlib, Version=4.0.0.0",
                    };

                    return(result);
                },
            });
        }
コード例 #25
0
 public virtual DescribedSerializationBase DeepCloneWithPayloadTypeRepresentation(TypeRepresentation payloadTypeRepresentation)
 {
     throw new NotImplementedException("This method should be abstract.  It was generated as virtual so that you aren't forced to override it when you create a new model that derives from this model.  It will be overridden in the generated designer file.");
 }
コード例 #26
0
        public override DescribedSerializationBase DeepCloneWithPayloadTypeRepresentation(TypeRepresentation payloadTypeRepresentation)
        {
            var result = new StringDescribedSerialization(
                payloadTypeRepresentation,
                this.SerializerRepresentation?.DeepClone(),
                this.SerializedPayload?.DeepClone());

            return(result);
        }
コード例 #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RunScheduleOp"/> class.
 /// </summary>
 /// <param name="deprecatedIdentifierType">OPTIONAL type to consider as a deprecated identifier (e.g. <see cref="T:Naos.Database.Domain.IdDeprecatedEvent" />).  DEFAULT is none.</param>
 public RunScheduleOp(
     TypeRepresentation deprecatedIdentifierType = null)
 {
     this.DeprecatedIdentifierType = deprecatedIdentifierType;
 }