示例#1
0
 static bool InitialStatesAreEqual(ProjectionState newInitialState, ProjectionState oldInitialState, ref ProjectionDefinitionComparisonResult result)
 {
     if (newInitialState != oldInitialState)
     {
         result = ProjectionDefinitionComparisonResult.Unequal("The initial projection state is not the same as the persisted definition");
         return(false);
     }
     return(true);
 }
示例#2
0
    static bool CopyToMongoDBsAreEqual(CopyToMongoDBSpecification newSpecification, CopyToMongoDBSpecification oldSpecification, ref ProjectionDefinitionComparisonResult result)
    {
        if (newSpecification.ShouldCopyToMongoDB != oldSpecification.ShouldCopyToMongoDB)
        {
            result = ProjectionDefinitionComparisonResult.Unequal("Should copy to MongoDB has changed from the previous projection definition");
            return(false);
        }

        if (newSpecification.Collection != oldSpecification.Collection)
        {
            result = ProjectionDefinitionComparisonResult.Unequal("Copy to MongoDB collection name has changed the previous projection definition");
            return(false);
        }

        return(CopyToMongoDBConversionsAreEqual(newSpecification.Conversions, oldSpecification.Conversions, ref result));
    }
示例#3
0
    static bool EventsAreEqual(IEnumerable <ProjectionEventSelector> newEvents, IEnumerable <ProjectionEventSelector> oldEvents, ref ProjectionDefinitionComparisonResult result)
    {
        if (newEvents.Count() != oldEvents.Count())
        {
            result = ProjectionDefinitionComparisonResult.Unequal("The definitions does not have the same number of events");
            return(false);
        }

        foreach (var newEvent in newEvents)
        {
            var oldEvent = oldEvents.FirstOrDefault(_ => _.EventType == newEvent.EventType);
            if (oldEvent == default)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Event {newEvent.EventType.Value} was not in previous projection definition");
                return(false);
            }

            if (oldEvent.KeySelectorType != newEvent.KeySelectorType)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Event {newEvent.EventType.Value} does not have the same key selector type");
                return(false);
            }

            if (oldEvent.KeySelectorExpression != newEvent.KeySelectorExpression)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Event {newEvent.EventType.Value} does not have the same key selector expressions");
                return(false);
            }

            if (oldEvent.StaticKey != newEvent.StaticKey)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Event {newEvent.EventType.Value} does not have the same static key");
                return(false);
            }

            if (oldEvent.OccurredFormat != newEvent.OccurredFormat)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Event {newEvent.EventType.Value} does not have the occurred format");
                return(false);
            }
        }

        return(true);
    }
示例#4
0
    static bool CopyToMongoDBConversionsAreEqual(PropertyConversion[] newConversions, PropertyConversion[] oldConversions, ref ProjectionDefinitionComparisonResult result)
    {
        if (newConversions.Length != oldConversions.Length)
        {
            result = ProjectionDefinitionComparisonResult.Unequal("Copy to MongoDB does not have the same number of conversions as the previous projection definition");
            return(false);
        }

        foreach (var newConversion in newConversions)
        {
            var oldConversion = Array.Find(oldConversions, oldConversion => oldConversion.Property == newConversion.Property);
            if (oldConversion == default)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Copy to MongoDB conversion for property {newConversion.Property} did not exist in the previous projection definition");
                return(false);
            }

            if (newConversion.Conversion != oldConversion.Conversion)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Copy to MongoDB conversion for property {newConversion.Property} has changed from the previous projection definition");
                return(false);
            }

            if (newConversion.ShouldRename != oldConversion.ShouldRename)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Copy to MongoDB should rename for property {newConversion.Property} has changed from the previous projection definition");
                return(false);
            }

            if (newConversion.RenameTo != oldConversion.RenameTo)
            {
                result = ProjectionDefinitionComparisonResult.Unequal($"Copy to MongoDB rename to for property {newConversion.Property} has changed from the previous projection definition");
                return(false);
            }

            if (!CopyToMongoDBConversionsAreEqual(newConversion.Children, oldConversion.Children, ref result))
            {
                return(false);
            }
        }

        return(true);
    }