Exemple #1
0
        public void CreateTemporaryInstance_Creates_Starts_And_Deletes_An_Instance(bool deleteFiles)
        {
            // Arrange
            if (!SqlLocalDbApi.IsWindows)
            {
                // HACK Theories dont seem to work correctly with subclasses now
                // so cannot make a derived class for a "Windows-only" theory.
                return;
            }

            using (var api = new SqlLocalDbApi(_loggerFactory))
            {
                ISqlLocalDbInstanceInfo info;
                string name;

                // Act
                using (TemporarySqlLocalDbInstance target = api.CreateTemporaryInstance(deleteFiles))
                {
                    // Assert
                    target.ShouldNotBeNull();
                    target.Name.ShouldNotBeNull();
                    target.Name.ShouldNotBeEmpty();

                    Guid.TryParse(target.Name, out Guid nameAsGuid).ShouldBeTrue();
                    nameAsGuid.ShouldNotBe(Guid.Empty);

                    // Act
                    info = target.GetInstanceInfo();

                    // Assert
                    info.ShouldNotBeNull();
                    info.Exists.ShouldBeTrue();
                    info.IsRunning.ShouldBeTrue();

                    name = target.Name;
                }

                // Act
                info = api.GetInstanceInfo(name);

                // Assert
                info.ShouldNotBeNull();
                info.Exists.ShouldBeFalse();
            }
        }
        private void CreateTemporaryInstance_Creates_Starts_And_Deletes_An_Instance(bool deleteFiles)
        {
            // Arrange
            using (var api = new SqlLocalDbApi(_loggerFactory))
            {
                ISqlLocalDbInstanceInfo info;
                string name;

                // Act
                using (TemporarySqlLocalDbInstance target = api.CreateTemporaryInstance(deleteFiles))
                {
                    // Assert
                    target.ShouldNotBeNull();
                    target.Name.ShouldNotBeNull();
                    target.Name.ShouldNotBeEmpty();

                    Guid.TryParse(target.Name, out Guid nameAsGuid).ShouldBeTrue();
                    nameAsGuid.ShouldNotBe(Guid.Empty);

                    // Act
                    info = target.GetInstanceInfo();

                    // Assert
                    info.ShouldNotBeNull();
                    info.Exists.ShouldBeTrue();
                    info.IsRunning.ShouldBeTrue();

                    name = target.Name;
                }

                // Act
                info = api.GetInstanceInfo(name);

                // Assert
                info.ShouldNotBeNull();
                info.Exists.ShouldBeFalse();
            }
        }