コード例 #1
0
        private static UserDetails CreateUserDetails(IEnumerable <string> directoriesUsed)
        {
            var userDetails = new UserDetails();

            foreach (var directory in directoriesUsed)
            {
                userDetails.AddSage50DataLocation(directory);
            }
            return(userDetails);
        }
コード例 #2
0
        public void CanRecallSavedDataFromDefaultLocation()
        {
            //given a storage which uses the default location
            var storage = new UserDetailsStorage(new FileSystem());

            //which has some data saved in it
            var savedDetails = new UserDetails();

            savedDetails.AddSage50DataLocation("c:\\Audition\\Sage50");
            storage.Save(savedDetails);

            //then the details can be loaded correctly
            var loadedDetails = storage.Load();

            CollectionAssert.AreEqual(new[] { "c:\\Audition\\Sage50" }, loadedDetails.Sage50DataLocations);
        }
コード例 #3
0
        public void CanRecallSavedData()
        {
            //given some user details
            var savedDetails = new UserDetails();

            savedDetails.AddSage50DataLocation("a location");

            //when we save them to a storage which does not already have some data
            var storage = CreateStorage();

            storage.Save(savedDetails);

            //then the details can be loaded correctly
            var loadedDetails = storage.Load();

            CollectionAssert.AreEqual(new[] { "a location" }, loadedDetails.Sage50DataLocations);
        }
コード例 #4
0
        public void WhenPathDoesNotExistItIsCreated()
        {
            //given a storage pointing at a path which does not exist
            var directoryWhichDoesNotExist   = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
            var fileOnPathWhichDoesnNotExist = Path.Combine(directoryWhichDoesNotExist, Path.GetRandomFileName());
            var storage = new UserDetailsStorage(new FileSystem(), fileOnPathWhichDoesnNotExist);

            //and some details
            var userDetails = new UserDetails();

            userDetails.AddSage50DataLocation("something");

            //when we try to save the details
            storage.Save(userDetails);


            //then the collection is saved and can be retrieved successfully
            var loadedDetails = storage.Load();

            CollectionAssert.AreEqual(new[] { "something" }, loadedDetails.Sage50DataLocations);
        }