Beispiel #1
0
        public void deveRetornarMenosUmParaValorInexistente()
        {
            NewCollection collection = new NewCollection();

            collection.Add("ano", "1979");
            collection.Add("mes", "Agosto");
            collection.Add("mes", "Fevereiro");
            long retorno = collection.IndexOf("ano", "2017");

            Assert.AreEqual(-1, retorno);
        }
Beispiel #2
0
        public void deveRemoverChavePassada()
        {
            NewCollection collection = new NewCollection();

            collection.Add("ano", "1979");
            collection.Add("mes", "Agosto");
            collection.Add("dia", "02");
            collection.Remove("ano");
            IList <string> retorno = new List <string>();

            retorno = collection.Get("ano", 0, 2);

            IList <string> result = new List <string>();

            Assert.AreEqual(result.ToString(), retorno.ToString());
        }
Beispiel #3
0
        public void deveRetornarListaDoPrimeiroAoPenultimo()
        {
            NewCollection collection = new NewCollection();

            collection.Add("ano", "1979");
            collection.Add("ano", "1994");
            collection.Add("ano", "2007");
            IList <string> retorno = new List <string>();

            retorno = collection.Get("ano", -1, -2);

            IList <string> result = new List <string>();

            result.Add("1979");
            result.Add("1994");

            Assert.AreEqual(result.ToString(), retorno.ToString());
        }
Beispiel #4
0
        public void deveRetornarListaComTodosItensDaChave()
        {
            NewCollection collection = new NewCollection();

            collection.Add("ano", "1979");
            collection.Add("ano", "1994");
            collection.Add("ano", "2007");
            IList <string> retorno = new List <string>();

            retorno = collection.Get("ano", 0, 4);

            IList <string> result = new List <string>();

            result.Add("1979");
            result.Add("1994");
            result.Add("2007");

            Assert.AreEqual(result.ToString(), retorno.ToString());
        }
Beispiel #5
0
        static void chapter1()
        {
            NewCollection names = new NewCollection();

            names.Add("David");
            names.Add("Bernica");
            names.Add("Raymond");
            names.Add("Clayton");
            foreach (Object name in names)
            {
                Console.WriteLine(name);
            }
            String numOfNames = "Number of names: {0}";

            Console.WriteLine(numOfNames, names.Count());
            names.Remove("Raymond");
            Console.WriteLine(numOfNames, names.Count());
            names.Clear();
            Console.WriteLine(numOfNames, names.Count());
        }
Beispiel #6
0
        public void CountChangedTest()
        {
            NewCollection <Place> places = new NewCollection <Place>("Тестовая коллекция");
            Journal j = new Journal("Тестовый журнал");

            places.CollectionCountChanged += new CollectionHandler(j.CollectionCountChanged);

            //Act
            places.Add(new Place());
            places.Remove(new Place());

            //Assert
            Assert.AreEqual(2, j.Count);
        }
Beispiel #7
0
        public void deveRetornarIndiceCorreto()
        {
            NewCollection collection = new NewCollection();

            collection.Add("ano", "1979");
            collection.Add("mes", "Agosto");
            collection.Add("ano", "2007");
            collection.Add("mes", "Fevereiro");
            collection.Add("ano", "1994");
            collection.Add("mes", "Março");
            collection.Add("ano", "2004");
            collection.Add("ano", "1978");
            long retorno = collection.IndexOf("ano", "2007");

            Assert.AreEqual(4, retorno);
        }
Beispiel #8
0
        public void ReferenceChangedTest()
        {
            NewCollection <Place> places = new NewCollection <Place>("Тестовая коллекция");
            Journal j = new Journal("Тестовый журнал");

            places.CollectionReferenceChanged += new CollectionHandler(j.CollectionReferenceChanged);
            places.Add(new Place());
            places.Add(new Region());

            places.Add(new Place());
            places.Add(new Region());
            places.Add(new Place());
            places.Add(new Address());

            places[1] = new Address();

            //Assert
            Assert.AreEqual(1, j.Count);
        }