示例#1
0
        static void Heroes()
        {
            var justiceLeague = new JusticeLeague();

            var batman   = justiceLeague["batman"].Clone() as Hero;
            var flash    = justiceLeague["FLash"].Clone() as Hero;
            var superman = justiceLeague["SUPERMAN"].Clone() as Hero;

            Console.ReadKey();
        }
        public void GetHero_Should_Return_Null()
        {
            // Arrange
            string          connectionString = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString;
            IGenericContext db   = new JusticeLeague(connectionString);
            Repository      repo = new Repository(db);

            // Act
            IHero sut = repo.GetHero(0);

            // Assert
            Assert.IsNull(sut);
        }
        public void GetHeroes_Should_Return_Hero_List()
        {
            // Arrange
            string          connectionString = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString;
            IGenericContext db   = new JusticeLeague(connectionString);
            Repository      repo = new Repository(db);

            // Act
            List <IHero> sut = repo.GetHeroes();

            // Assert
            Assert.IsNotNull(sut);
            Assert.IsInstanceOfType(sut, typeof(List <IHero>));
        }
        public void GetHero_Should_Return_Hero()
        {
            // Arrange
            string          connectionString = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString;
            IGenericContext db   = new JusticeLeague(connectionString);
            Repository      repo = new Repository(db);

            // Act
            IHero sut = repo.GetHero(1);

            // Assert
            Assert.IsNotNull(sut);
            Assert.IsNotNull(sut.Id);
            Assert.IsNotNull(sut.Name);
            Assert.IsNotNull(sut.Stars);
            Assert.IsNotNull(sut.Level);
            Assert.IsNotNull(sut.Description);
            Assert.IsNotNull(sut.HeroClass);
            Assert.IsInstanceOfType(sut, typeof(IHero));
        }