Exemplo n.º 1
0
 protected override void Arrange()
 {
     base.Arrange();
     base.Act();
     StubNew(ref Code.New, ExpectedInstance);
     SpaceRemover.Stub(x => x.Remove(code)).Return(code);
 }
Exemplo n.º 2
0
        public void ShouldRemoveAllSpacesInStringWithoutConsecutiveSpaces()
        {
            string s = "Mr John Smith is a teacher          ";

            char[] stringWithSpaces    = s.ToCharArray(0, s.Length);
            char[] stringWithoutSpaces = SpaceRemover.RemoveSpaces(stringWithSpaces);

            Assert.Equal("Mr%20John%20Smith%20is%20a%20teacher", new string(stringWithoutSpaces));
        }
Exemplo n.º 3
0
        public void ShouldRemoveAllSpacesInStringWithoutConsecutiveSpacesAndStartingWithSpace()
        {
            string s = " Mr John Smith      ";

            char[] stringWithSpaces    = s.ToCharArray(0, s.Length);
            char[] stringWithoutSpaces = SpaceRemover.RemoveSpaces(stringWithSpaces);

            Assert.Equal("%20Mr%20John%20Smith", new string(stringWithoutSpaces));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reads the local file.
        /// </summary>
        /// <returns>GeoJSONData in raw format.</returns>
        public GeoJSONData ReadLocalFile()
        {
            GeoJSONData data    = new GeoJSONData();
            string      content = "";

            using (var input = context.Assets.Open(FileName))
                using (StreamReader sr = new System.IO.StreamReader(input))
                {
                    string temp = sr.ReadLine();
                    while (true)
                    {
                        if (string.IsNullOrEmpty(temp))
                        {
                            break;
                        }
                        content += temp + "\n";
                        temp     = sr.ReadLine();
                    }
                }
            var geoData = new GeoJSONData();

            geoData.Data = content;
            var tempList = new List <VenueLocation>();

            using (var input = context.Assets.Open(FileName1))
                using (StreamReader sr = new StreamReader(input))
                {
                    string temp = sr.ReadLine();
                    while (true)
                    {
                        if (string.IsNullOrEmpty(temp))
                        {
                            break;
                        }
                        var subject = "";
                        var index   = 0;
                        for (int i = 0; i < temp.Length; i++, index++)
                        {
                            if (temp[i] != '[')
                            {
                                subject += temp[i];
                            }
                            else
                            {
                                index++;                         //skip over the '['
                                break;
                            }
                        }
                        var venue = "";
                        subject = new SpaceRemover(subject).RemovedSpaces;
                        for (int a = index; a < temp.Length; a++)
                        {
                            var ch = temp[a];
                            if (temp[a] == ']')
                            {
                                break;
                            }
                            else
                            {
                                venue += temp[index++];
                            }
                        }
                        var tempVenueLoc = new VenueLocation {
                            Name = venue
                        };
                        tempList.Add(tempVenueLoc);
                        temp = sr.ReadLine();
                    }
                }
            var result = string.Join(",", tempList);

            loc = tempList;
            return(geoData);
        }
Exemplo n.º 5
0
 private static string Normalize(string text) =>
 SpaceRemover.Replace(text.Trim().Replace(Environment.NewLine, " "), " ");
Exemplo n.º 6
0
        public GeoJSONData Process()
        {
            var    content  = "";
            var    content2 = "";
            var    current  = Directory.GetCurrentDirectory();
            var    text     = System.IO.File.OpenText("Files/RhodesMap.geojson");
            string temp     = text.ReadLine();

            while (true)
            {
                if (string.IsNullOrEmpty(temp))
                {
                    break;
                }
                content += temp + "\n";
                temp     = text.ReadLine();
            }
            GeoJSONData geoData = new GeoJSONData {
                Data = content
            };

            text = System.IO.File.OpenText("Files/Venues.txt");
            temp = text.ReadLine();
            var tempList = new List <VenueLocation>();

            while (true)
            {
                if (string.IsNullOrEmpty(temp))
                {
                    break;
                }
                var subject = "";
                var index   = 0;
                for (int i = 0; i < temp.Length; i++, index++)
                {
                    if (temp[i] != '[')
                    {
                        subject += temp[i];
                    }
                    else
                    {
                        index++;                                 //skip over the '['
                        break;
                    }
                }
                var venue = "";
                subject = new SpaceRemover(subject).RemovedSpaces;
                for (int a = index; a < temp.Length; a++)
                {
                    if (temp[a] == ']')
                    {
                        break;
                    }
                    else
                    {
                        venue += temp[index++];
                    }
                }
                var tempVenueLoc = new VenueLocation {
                    Name = venue
                };
                tempList.Add(tempVenueLoc);
                temp = text.ReadLine();
            }
            loc = tempList;
            return(geoData);
        }
Exemplo n.º 7
0
 protected override void Act()
 {
     Sut = new SpaceRemover();
 }
Exemplo n.º 8
0
 protected override void Act()
 {
     Sut = new SpaceRemover();
 }