public void DetectionIsEmulatorOnly_IncompleteSomeRequiredVariables()
            {
                var builder     = new FakeBuilder(EmulatorDetection.EmulatorOnly);
                var environment = CreateEnvironmentDictionary(Required1);

                Assert.Throws <InvalidOperationException>(() => builder.GetEmulatorEnvironment(environment));
            }
            public void DetectionIsProductionOnly_NoVariables()
            {
                var builder     = new FakeBuilder(EmulatorDetection.ProductionOnly);
                var environment = CreateEnvironmentDictionary();

                Assert.Null(builder.GetEmulatorEnvironment(environment));
            }
            public void DetectionIsProductionOnly_OptionalVariable()
            {
                var builder     = new FakeBuilder(EmulatorDetection.ProductionOnly);
                var environment = CreateEnvironmentDictionary(Optional1);

                Assert.Throws <InvalidOperationException>(() => builder.GetEmulatorEnvironment(environment));
            }
            public void DetectionIsEmulatorOrProduction_JustOptionalVariables()
            {
                var builder     = new FakeBuilder(EmulatorDetection.EmulatorOrProduction);
                var environment = CreateEnvironmentDictionary(Optional1, Optional2);

                Assert.Throws <InvalidOperationException>(() => builder.GetEmulatorEnvironment(environment));
            }
            public void DetectionIsNone_AllVariables()
            {
                var builder     = new FakeBuilder(EmulatorDetection.None);
                var environment = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2);

                Assert.Null(builder.GetEmulatorEnvironment(environment));
            }
            public void DetectionIsEmulatorOnly_RequiredVariableIsNull(string required2Value)
            {
                var builder     = new FakeBuilder(EmulatorDetection.EmulatorOnly);
                var environment = CreateEnvironmentDictionary(Required1);

                environment[Required2] = required2Value;
                Assert.Throws <InvalidOperationException>(() => builder.GetEmulatorEnvironment(environment));
            }
            public void DetectionIsEmulatorOrProduction_AllVariables()
            {
                var builder     = new FakeBuilder(EmulatorDetection.EmulatorOrProduction);
                var environment = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2, OtherVariable);
                var result      = builder.GetEmulatorEnvironment(environment);
                var expected    = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2);

                Assert.Equal(expected, result);
            }
            public void DetectionIsEmulatorOnly_NullAndWhitespaceConvertedToNull(string optional2Value)
            {
                var builder     = new FakeBuilder(EmulatorDetection.EmulatorOnly);
                var environment = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2);

                environment[Optional2] = optional2Value;
                var result = builder.GetEmulatorEnvironment(environment);

                // null, empty and whitespace are all converted to null in the returned environment.
                Assert.Null(result[Optional2]);
            }
            public void DetectionIsEmulatorOnly_AllVariables_WithAdditionalSettings()
            {
                // With EmulatorOnly, it's invalid to specify credentials etc.
                var builder = new FakeBuilder(EmulatorDetection.EmulatorOnly)
                {
                    CredentialsPath = "foo"
                };
                var environment = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2, OtherVariable);

                Assert.Throws <InvalidOperationException>(() => builder.GetEmulatorEnvironment(environment));
            }
            public void DetectionIsEmulatorOnly_AllRequiredVariables()
            {
                var builder     = new FakeBuilder(EmulatorDetection.EmulatorOnly);
                var environment = CreateEnvironmentDictionary(Required1, Required2, Optional1);
                var result      = builder.GetEmulatorEnvironment(environment);

                var expected = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2);

                // The Optional2 key should be present, but with a null value
                expected[Optional2] = null;
                Assert.Equal(expected, result);
            }
            public void DetectionIsEmulatorOrProduction_AllVariables_WithAdditionalSettings()
            {
                // With EmulatorOrProduction, it's valid to specify credentials etc.
                var builder = new FakeBuilder(EmulatorDetection.EmulatorOrProduction)
                {
                    CredentialsPath = "foo"
                };
                var environment = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2, OtherVariable);
                var result      = builder.GetEmulatorEnvironment(environment);
                var expected    = CreateEnvironmentDictionary(Required1, Required2, Optional1, Optional2);

                Assert.Equal(expected, result);
            }