示例#1
0
        public void Create_ThrowsException_WhenProfileWithSameNameAlreadyExists()
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            storage.Create("default");
        }
示例#2
0
        public void Create_CreatesNewCSV_WithTheNameOfTheProfile()
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            storage.Create("new");

            // Assert
            Assert.IsTrue(_fileSystem.FileExists(Path.Combine(FileSystemProfileStorage.PROFILE_FOLDER_PATH, "new.csv")));
        }
示例#3
0
        public void Exists_IsCaseInsensitive()
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            bool actual = storage.Exists("DEfault");

            // Assert
            Assert.IsTrue(actual);
        }
示例#4
0
        public void Exists_ReturnsTrue_OnlyWhenACSVWithTheSameNameExistsInTheFileSystem(string profileName, bool expected)
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            bool actual = storage.Exists(profileName);

            // Assert
            Assert.AreEqual(expected, actual);
        }
示例#5
0
        public void CreatingThenGettingAProfile_ReturnsTheSameInstance()
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            IProfile created = storage.Create("foo");
            IProfile gotten  = storage.Get("foo");

            // Assert
            Assert.AreSame(created, gotten);
        }
示例#6
0
        public void SubsequentProfileGets_ReturnTheSameProfileInstance()
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            IProfile resultOne = storage.Get("default");
            IProfile resultTwo = storage.Get("default");

            // Assert
            Assert.AreSame(resultOne, resultTwo);
        }
示例#7
0
        public void CreatingAndIteratingOverProfiles_ReturnsTheSameInstances()
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            IProfile created  = storage.Create("foo");
            IProfile iterated = storage.First(p => p.Name == "foo");

            // Assert
            Assert.AreSame(iterated, created);
        }
示例#8
0
        public void GettingAndIteratingOverProfiles_ReturnsTheSameInstances()
        {
            // Arrange
            FileSystemProfileStorage storage = new FileSystemProfileStorage(_fileSystem);

            // Act
            IProfile iterated = storage.First(p => p.Name == "default");
            IProfile gotten   = storage.Get("default");

            // Assert
            Assert.AreSame(iterated, gotten);
        }
示例#9
0
        private static void RegisterApplicationTypes(ContainerBuilder builder)
        {
            IProfileStorage profileStorage;

#if DEBUG_PROFILES
            // Debug configruation with existing profiles
            profileStorage = new Core.Services.Storage.InMemoryProfileStorage(new List <IProfile>()
            {
                new DesignTime.Profiles.Empty("Default"),
                new DesignTime.Profiles.Loser(),
                new DesignTime.Profiles.Winner(),
                new DesignTime.Profiles.FiveHundredMatches()
            });
#elif DEBUG_NEW_USER
            // Debug configuration with no profiles (new user)
            profileStorage = new Core.Services.Storage.InMemoryProfileStorage();
#else
            profileStorage = new FileSystemProfileStorage();
#endif
            builder.Register <IProfileStorage>((_) => profileStorage).SingleInstance();
            builder.RegisterType <Core.Services.ProfileManager>().AsSelf().AsImplementedInterfaces().SingleInstance();
        }