Beispiel #1
0
        protected virtual async Task OneTimeSetUpInternal(string initialConnectionString, string connectionString)
        {
            Settings.ConnectionStrings = new Dictionary <string, string>
            {
                { "EventStoreInitialize", initialConnectionString },
                { "EventStore", connectionString },
            };

            SqlStatementsLoader.LoadScripts();

            await CreateDatabaseAsync <SqlConnection>(Settings.ConnectionStrings["EventStoreInitialize"]);

            MockEventDataSerializer
            .Setup(m => m.Serialize(It.IsAny <Event>()))
            .Returns((Event @event) => JsonConvert.SerializeObject(@event));

            MockEventDataSerializer
            .Setup(m => m.Deserialize(It.IsAny <string>(), It.IsAny <string>()))
            .Returns((string jsonString, string type) =>
            {
                var jObj = JObject.Parse(jsonString);

                var version = jObj.GetValue("Version").Value <long>();

                var @event = (TestEvent)JsonConvert.DeserializeObject(jsonString, Type.GetType(type));

                @event.SetVersion(version);

                return(@event);
            });
        }
        public void WHEN__THEN_()
        {
            // Arrange
            var loader = new SqlStatementsLoader();

            // Act
            loader.LoadScripts();

            // Assert
            loader["Initialize"].Should().NotBeNullOrWhiteSpace();
            loader["GetByAggregateRootId"].Should().NotBeNullOrWhiteSpace();
            loader["Save"].Should().NotBeNullOrWhiteSpace();
        }