Ejemplo n.º 1
0
        public void CreateInstance_ValidData_ReturnsValidRebel()
        {
            //Arrange
            var validName   = "Pedro";
            var validPlanet = "Marte";

            //Act
            var rebel = RebelFactory.CreateInstance(validName, validPlanet);

            //Assert
            Assert.IsNotNull(rebel);
            Assert.IsNotNull(rebel.Name);
            Assert.IsNotNull(rebel.Planet);
            Assert.IsNotNull(rebel.DateTime);
            Assert.AreEqual(validName, rebel.Name);
            Assert.AreEqual(validPlanet, rebel.Planet);
        }
Ejemplo n.º 2
0
        public List <Rebel> SplitData(StringCollection collection)
        {
            if (collection == null)
            {
                throw new ServiceException("Collection null");
            }

            var rebelList = new List <Rebel>();

            foreach (var linea in collection)
            {
                try
                {
                    String[] data = linea.Split(',');
                    rebelList.Add(RebelFactory.CreateInstance(data[0], data[1]));
                }
                catch (Exception ex)
                {
                    throw new ServiceException("Error al recuperar los datos", ex);
                }
            }

            return(rebelList);
        }
Ejemplo n.º 3
0
 public void CreateInstance_EmptyPlanet_ThrowsModelException()
 {
     Assert.ThrowsException <ModelException>(() => RebelFactory.CreateInstance("Pedro", ""));
 }
Ejemplo n.º 4
0
 public void CreateInstance_EmptyName_ThrowsModelException()
 {
     Assert.ThrowsException <ModelException>(() => RebelFactory.CreateInstance("", "Marte"));
 }