public void ApplicationIsNotAddedWhenConfigurationIsNull()
        {
            var watchingConfigRepoMock = MockRepository.GenerateMock<IWatchingConfigurationRepository>();
            var repository = new InstalledApplicationRepository(watchingConfigRepoMock);

            watchingConfigRepoMock.Raise(x => x.Added += delegate { }, (IConfigurationElement)null);

            var applications = repository.Get();
            Assert.IsEmpty(applications);
        }
        public void ApplicationIsNotAddedWhenInstalledValueIsNotOne()
        {
            var watchingConfigRepoMock = MockRepository.GenerateMock<IWatchingConfigurationRepository>();
            var repository = new InstalledApplicationRepository(watchingConfigRepoMock);
            var mockConfig = MockRepository.GenerateMock<IConfigurationElement>();
            var mockUserConfig = MockRepository.GenerateMock<IConfigurationElement>();
            mockUserConfig.Stub(x => x.Name).Return("UserConfig");
            var attributes = new Dictionary<string, string>()
            {
                { "installed", "0" },
            };
            mockUserConfig.Stub(x => x.Attributes).Return(attributes);
            mockConfig.Stub(x => x.Children).Return(new[] { mockUserConfig });

            watchingConfigRepoMock.Raise(x => x.Added += delegate { }, mockConfig);

            var application = repository.Get().FirstOrDefault();
            Assert.IsNull(application);
        }
        public void DoesRepositoryGenerateApplicationWithCorrectValuesFromConfiguration()
        {
            var watchingConfigRepoMock = MockRepository.GenerateMock<IWatchingConfigurationRepository>();
            var repository = new InstalledApplicationRepository(watchingConfigRepoMock);
            var mockConfig = MockRepository.GenerateMock<IConfigurationElement>();
            var mockUserConfig = MockRepository.GenerateMock<IConfigurationElement>();
            mockUserConfig.Stub(x => x.Name).Return("UserConfig");
            var attributes = new Dictionary<string, string>()
            {
                { "installed", "1" },
                { "gameid", "100" },
                { "name", "test" }
            };
            mockUserConfig.Stub(x => x.Attributes).Return(attributes);
            mockConfig.Stub(x => x.Children).Return(new[] { mockUserConfig });

            watchingConfigRepoMock.Raise(x => x.Added += delegate { }, mockConfig);

            var application = repository.Get().FirstOrDefault();
            Assert.IsNotNull(application);

            Assert.AreEqual(int.Parse(attributes["gameid"]), application.Id);
            Assert.AreEqual(attributes["name"], application.Name);
        }