static void TestLoad(bool useParameterless) { var targetEnv = EnvironmentRepositoryTest.CreateMockEnvironment(EnvironmentRepositoryTest.Server1Source); var repository = new Mock <IServerRepository>(); repository.Setup(r => r.All()).Returns(new[] { targetEnv.Object }); CustomContainer.DeRegister <IServerRepository>(); CustomContainer.Register(repository.Object); if (useParameterless) { ServerRepository.Instance.IsLoaded = true; // so that we don't connect to a server! ServerRepository.Instance.Clear(); ServerRepository.Instance.Save(targetEnv.Object); } var provider = new TestServerProvider(); var servers = useParameterless ? provider.Load() : provider.Load(repository.Object); Assert.AreEqual(1, servers.Count); Assert.AreSame(servers[0], targetEnv.Object); Assert.AreEqual(servers[0].EnvironmentID, targetEnv.Object.EnvironmentID); Assert.AreEqual(servers[0].Name, targetEnv.Object.Name); // remove the last two properties from mock ;) }
public void ServerProviderLoadWithNullEnvironmentRepositoryExpectedThrowsArgumentNullException() { var provider = new TestServerProvider(); provider.Load(null); }
static void TestLoad(bool useParameterless) { var targetEnv = EnviromentRepositoryTest.CreateMockEnvironment(EnviromentRepositoryTest.Server1Source); var repository = new Mock<IEnvironmentRepository>(); repository.Setup(r => r.All()).Returns(new[] { targetEnv.Object }); if(useParameterless) { EnvironmentRepository.Instance.Clear(); EnvironmentRepository.Instance.Save(targetEnv.Object); EnvironmentRepository.Instance.IsLoaded = true; // so that we don't connect to a server! } var provider = new TestServerProvider(); var servers = useParameterless ? provider.Load() : provider.Load(repository.Object); Assert.AreEqual(1, servers.Count); Assert.AreSame(servers[0], targetEnv.Object); Assert.AreEqual(servers[0].ID, targetEnv.Object.ID); Assert.AreEqual(servers[0].Name, targetEnv.Object.Name); // remove the last two properties from mock ;) }