Exemplo n.º 1
0
        public void ConfigurationPerformTestSuccessfulTest()
        {
            var model = new AmpacheModel();
            var factory = Substitute.For<AmpacheSelectionFactory>();
            model.Factory = factory;
            factory.AuthenticationTest(Arg.Any<string>(),Arg.Any<string>(),Arg.Any<string>()).Returns((Authenticate)null);

            var target = new Configuration(model);
            Assert.That(model.UserMessage, Is.Null);
            target.PerformTest(string.Empty, string.Empty, string.Empty);
            Assert.That(model.UserMessage, Is.Not.Null);
        }
Exemplo n.º 2
0
        public void ConfigurationPerformTestErrorTest()
        {
            var model = new AmpacheModel();
            var factory = Substitute.For<AmpacheSelectionFactory>();
            model.Factory = factory;
            var message = "error message";
            factory.When(x => x.AuthenticationTest(Arg.Any<string>(),Arg.Any<string>(),Arg.Any<string>())).Do((obj) => { throw new Exception(message); });

            var target = new Configuration(model);
            Assert.That(model.UserMessage, Is.Null);
            target.PerformTest(string.Empty, string.Empty, string.Empty);
            Assert.That(model.UserMessage, Is.SameAs(message));
        }
Exemplo n.º 3
0
 public void ConfigurationTrySaveConfigurationFailsByDefault()
 {
     var target = new Configuration(null);
     var res = target.TrySaveConfiguration(new UserConfiguration());
     Assert.That(res, Is.False);
 }
Exemplo n.º 4
0
        public void ConfigurationTrySaveConfigurationErrorTest()
        {
            var model = new AmpacheModel();
            var factory = Substitute.For<AmpacheSelectionFactory>();
            model.Factory = factory;
            var message = "error message";
            factory.When(x => x.AuthenticateToServer(Arg.Any<UserConfiguration>())).Do((obj) => { throw new Exception(message); });

            var target = new Configuration(model);
            Assert.That(model.UserMessage, Is.Null);
            var conf = new UserConfiguration();
            var actual = target.TrySaveConfiguration(conf);
            Assert.That(actual, Is.False);
            Assert.That(model.UserMessage, Is.SameAs(message));
            Assert.That(model.Configuration, Is.Null);
        }
Exemplo n.º 5
0
 public void ConfigurationTrySaveNullInputTest()
 {
     var model = new AmpacheModel();
     var target = new Configuration(model);
     Assert.That(model.UserMessage, Is.Null);
     var actual = target.TrySaveConfiguration(null);
     Assert.That(actual, Is.False);
 }
Exemplo n.º 6
0
        public void ConfigurationTrySaveConfigurationSuccessfulTest()
        {
            var model = new AmpacheModel();
            var factory = Substitute.For<AmpacheSelectionFactory>();
            model.Factory = factory;
            factory.AuthenticateToServer(Arg.Any<UserConfiguration>()).Returns((Authenticate)null);

            var target = new Configuration(model);
            Assert.That(model.UserMessage, Is.Null);
            var conf = new UserConfiguration();
            var actual = target.TrySaveConfiguration(conf);
            Assert.That(actual, Is.True);
            Assert.That(model.UserMessage, Is.Not.Null);
            Assert.That(model.Configuration, Is.SameAs(conf));
        }