コード例 #1
0
        public Event Create(int version)
        {
            var accountObject = BankAccountEventFactory.CreateAccountObject(version);

            var serializedObject = Codec.Json.To(accountObject);
            var @event           = new Event(Guid.NewGuid(), accountObject.GetType().FullName, false, Encoding.UTF8.GetBytes(serializedObject), new byte[0]);

            return(@event);
        }
コード例 #2
0
        public Event Create(int version)
        {
            var accountObject = BankAccountEventFactory.CreateAccountObject(version);

            var serializedObject = Codec.Json.To(accountObject);
            var @event           = new Event(Guid.NewGuid(), accountObject.GetType().Name, true, Helper.UTF8NoBom.GetBytes(serializedObject), new byte[0]);

            return(@event);
        }
コード例 #3
0
        public bool Equal(int eventVersion, string eventType, byte[] actualData)
        {
            var    generated = BankAccountEventFactory.CreateAccountObject(eventVersion);
            object deserialized;

            bool   isEqual;
            string reason;

            if (actualData == null)
            {
                isEqual = false;
                reason  = "Null received";
            }
            else
            {
                deserialized = Deserialize(eventType, actualData);

                if (deserialized.GetType() != generated.GetType())
                {
                    isEqual = false;
                    reason  = string.Format("Type does not match, actual type is {0}", deserialized.GetType().FullName);
                }
                else
                {
                    isEqual = generated.Equals(deserialized);
                    reason  = "Value differs";
                }
            }

            if (!isEqual)
            {
                LogExpected(generated, actualData, reason);
            }

            return(isEqual);
        }