コード例 #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            MapperConfiguration configMapper = new MapperConfiguration(
                cfg => { cfg.AddProfile(new AutoMapperProfile()); }
                );

            AutomapperConfiguration.Configure();

            services.AddMvc();

            services.AddScoped <IUnitOfWork, IdentityUnitOfWork>();
            services.AddScoped <IFanficService, FanficService>();
            services.AddScoped <IFanficTagsService, FanficTagsService>();
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <IChapterService, ChapterService>();
            services.AddScoped <IChapterRatingService, ChapterRatingService>();
            services.AddScoped <ICommentService, CommentService>();
            services.AddScoped <ICommentRatingService, CommentRatingService>();
            services.AddScoped <IGenreService, GenreService>();
            services.AddScoped <ITagService, TagService>();
            services.AddSingleton(Configuration);
            services.AddSingleton(ctx => configMapper.CreateMapper());

            System.IO.File.WriteAllText("D:/startup.txt", Configuration.GetConnectionString("ApplicationContext"));

            services.AddDbContext <ApplicationContext>(options => {
                options.UseSqlServer(Configuration.GetConnectionString("ApplicationContext"), b => b.MigrationsAssembly("iFanfics.Migrations"));
            });

            services.AddIdentity <ApplicationUser, IdentityRole>(opts => { opts.User.RequireUniqueEmail = true; })
            .AddEntityFrameworkStores <ApplicationContext>()
            .AddDefaultTokenProviders();
        }
コード例 #2
0
        /// <summary>
        ///     Configuration IAppBuilder
        /// </summary>
        /// <param name="app"></param>
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            AutofacConfig.Configure(config);
            AuthConfig.Configure(app);

            //WebApiConfig.Register(config);
            app.UseCors(CorsOptions.AllowAll);
            app.UseWebApi(config);
            Database.SetInitializer(new MigrateDatabaseToLatestVersion <SampleAppContext, Configuration>());

            //old
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            AutomapperConfiguration.Configure();

            ConfigureOAuthTokenGeneration(app);
            //Repository.Classes.Shared.AuthRepository authorRepo = new Repository.Classes.Shared.AuthRepository(new SampleAppContext());
            //authorRepo.CreateDefaultRolesandUsers();
        }
コード例 #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            MapperConfiguration configMapper = new MapperConfiguration(
                cfg => { cfg.AddProfile(new AutoMapperProfile()); }
                );

            AutomapperConfiguration.Configure();
            services.AddSingleton(ctx => configMapper.CreateMapper());
            services.AddSingleton(Configuration);
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            services.AddScoped <IUserService, UserService>();
            services.AddScoped <IMessageService, MessageService>();
            services.AddScoped <IGroupService, GroupServise>();
            services.AddScoped <IGroupUserService, GroupUserServise>();
            services.AddScoped <IConnectedUsersService, ConnectedUsersService>();



            services.AddDbContext <ApplicationContext>(options => options.UseSqlServer(Configuration.GetConnectionString("ApplicationContext"), b => b.MigrationsAssembly("MessengerApi.Migrations")));

            services.AddIdentity <ApplicationUser, IdentityRole>(opts => { opts.User.RequireUniqueEmail = true; })
            .AddEntityFrameworkStores <ApplicationContext>()
            .AddDefaultTokenProviders();

            services.AddSingleton <Microsoft.Extensions.Hosting.IHostedService, ServerObject>();

            services.AddMvc();

            services.AddSignalR();
        }
コード例 #4
0
        public virtual void SetUp()
        {
            autoMocker = new RhinoAutoMocker <GameDefinitionController>();
            autoMocker.Get <IGameDefinitionRetriever>()
            .Expect(mock => mock.GetTrendingGames(GameDefinitionController.NUMBER_OF_TRENDING_GAMES_TO_SHOW,
                                                  GameDefinitionController.NUMBER_OF_DAYS_OF_TRENDING_GAMES))
            .Return(trendingGames);
            AutomapperConfiguration.Configure();
            urlHelperMock = MockRepository.GenerateMock <UrlHelper>();
            autoMocker.ClassUnderTest.Url = urlHelperMock;

            asyncRequestMock = MockRepository.GenerateMock <HttpRequestBase>();
            asyncRequestMock.Expect(x => x.Headers)
            .Repeat.Any()
            .Return(new System.Net.WebHeaderCollection
            {
                { "X-Requested-With", "XMLHttpRequest" }
            });

            var context = MockRepository.GenerateMock <HttpContextBase>();

            context.Expect(x => x.Request)
            .Repeat.Any()
            .Return(asyncRequestMock);
            autoMocker.ClassUnderTest.ControllerContext = new ControllerContext(context, new RouteData(), autoMocker.ClassUnderTest);
            currentUser = new ApplicationUser()
            {
                Id = "user id",
                CurrentGamingGroupId = 15151
            };
        }
コード例 #5
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Mapper.Initialize(cfg => { AutomapperConfiguration.Configure(cfg); });
            DependencyResolver.Start();

            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }
コード例 #6
0
        public static void ConfigureBusinessServices(this IServiceCollection services)
        {
            services.ConfigureRepositoryServices();

            services.AddScoped <IUserService, UserService>();

            services.AddSingleton(AutomapperConfiguration.Configure().CreateMapper());
        }
コード例 #7
0
        public static void Run()
        {
            // Configure Autofac
            AutofacWebapiConfig.Initialize(GlobalConfiguration.Configuration);

            // Configure AutoMapper
            AutomapperConfiguration.Configure();
        }
コード例 #8
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            kernel.Bind <IUserService>().To <UserService>();
            kernel.Bind <IPetService>().To <PetService>();

            var automapperConfig = new AutomapperConfiguration();

            kernel.Bind <IMapper>().ToConstant(automapperConfig.Configure().CreateMapper()).InSingletonScope();
        }
コード例 #9
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AutomapperConfiguration.Configure();
     ContainerConfiguration.ConfigureContainer();
 }
コード例 #10
0
        public virtual void SetUp()
        {
            AutomapperConfiguration.Configure();
            _autoMocker = new RhinoAutoMocker <HomeController>();

            _autoMocker.Inject <IMapperFactory>(new MapperFactory(new Container(c =>
            {
                c.AddRegistry <TestRegistry>();
            })));
        }
コード例 #11
0
ファイル: Global.asax.cs プロジェクト: hunghv/Elearn_ICT
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     //hunghv2 init config auto mapper
     AutomapperConfiguration.Configure();
 }
コード例 #12
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            _applicationWideWindsorContainer.Install(new WindsorInstaller());
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(_applicationWideWindsorContainer));

            AutomapperConfiguration.Configure();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
コード例 #13
0
        public void Before()
        {
            var builder = new TestControllerBuilder();

            _postRepository = MockRepository.GenerateStub <IPostRepository>();
            _postRepository.Stub(x => x.GetAllPost()).Return(new List <Post>());
            // using real automapper
            AutomapperConfiguration.Configure();

            _sut = new HomeController(_postRepository, new AutomapperWrapper());
            builder.InitializeController(_sut);
        }
コード例 #14
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //  don't want to set an initializer since we are doing code first with migrations
            //  and the Configuration will call the DataSeeder.
            Database.SetInitializer <NemeStatsDbContext>(null);
            AutomapperConfiguration.Configure();
        }
コード例 #15
0
ファイル: ModuleLoader.cs プロジェクト: BullFrog13/Akvelon_HT
        public void LoadAssemblyBindings(IKernel kernel)
        {
            var modules = new INinjectModule[] { new ServiceModule("UserDB") };

            kernel.Load(modules);

            kernel.Bind <IUserService>().To <BLL.Services.UserService>();

            var config = new AutomapperConfiguration();
            var mapper = config.Configure().CreateMapper();

            kernel.Bind <IMapper>().ToConstant(mapper).InSingletonScope();
        }
コード例 #16
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Load map entity -> viewmodels
            AutomapperConfiguration.Configure();

            //--> Autofac
            AutofacConfiguration.Register();
        }
コード例 #17
0
        protected void Application_Start()
        {
            _container = Bootstrapper.InitializeContainer();

            AutomapperConfiguration.Configure();
            AreaRegistration.RegisterAllAreas();

            HiperionConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <UserContext>());
        }
コード例 #18
0
 public virtual void SetUp()
 {
     AutomapperConfiguration.Configure();
     playerSummaryBuilderMock          = MockRepository.GenerateMock <IPlayerSummaryBuilder>();
     topPlayerViewModelBuilderMock     = MockRepository.GenerateMock <ITopPlayerViewModelBuilder>();
     playedGameRetrieverMock           = MockRepository.GenerateMock <IPlayedGameRetriever>();
     nemesisHistoryRetrieverMock       = MockRepository.GenerateMock <INemesisHistoryRetriever>();
     nemesisChangeViewModelBuilderMock = MockRepository.GenerateMock <INemesisChangeViewModelBuilder>();
     gamingGroupRetrieverMock          = MockRepository.GenerateMock <IGamingGroupRetriever>();
     homeControllerPartialMock         = MockRepository.GeneratePartialMock <HomeController>(
         playerSummaryBuilderMock,
         topPlayerViewModelBuilderMock,
         playedGameRetrieverMock,
         nemesisHistoryRetrieverMock,
         nemesisChangeViewModelBuilderMock,
         gamingGroupRetrieverMock);
 }
コード例 #19
0
        protected void Application_Start()
        {
            MiniProfilerEF6.Initialize();

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var container = AutofacConfig.Register();

            AutomapperConfiguration.Configure(container);
            QuartzStart.Run();

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorThemeViewEngine());
        }
コード例 #20
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            RouteConfig.RegisterRoutes(RouteTable.Routes);

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ConfigureDependencyInjection();

            AutomapperConfiguration.Configure <WebLayerMapperProfile>(cfg =>
            {
                cfg.AddProfile(new ServiceLayerMapperProfile());
                cfg.IgnoreUnmapped();
            });
        }
コード例 #21
0
        public void BaseSetUp()
        {
            AutomapperConfiguration.Configure();
            this.autoMocker = new RhinoAutoMocker <T>();
            var controllerContextMock = MockRepository.GeneratePartialMock <HttpControllerContext>();
            var actionDescriptorMock  = MockRepository.GenerateMock <HttpActionDescriptor>();

            this.autoMocker.ClassUnderTest.ActionContext = new HttpActionContext(controllerContextMock, actionDescriptorMock);

            this.applicationUser = new ApplicationUser
            {
                Id = "application user id",
                CurrentGamingGroupId = EXPECTED_GAMING_GROUP_ID
            };
            autoMocker.ClassUnderTest.CurrentUser = this.applicationUser;

            this.autoMocker.ClassUnderTest.Request = new HttpRequestMessage();
            this.autoMocker.ClassUnderTest.Request.SetConfiguration(new HttpConfiguration());
        }
コード例 #22
0
        public virtual void SetUp()
        {
            AutomapperConfiguration.Configure();
            dataContextMock                   = MockRepository.GenerateMock <NemeStatsDataContext>();
            gameDefinitionRetrieverMock       = MockRepository.GenerateMock <IGameDefinitionRetriever>();
            gameDefinitionTransformationMock  = MockRepository.GenerateMock <IGameDefinitionDetailsViewModelBuilder>();
            showingXResultsMessageBuilderMock = MockRepository.GenerateMock <IShowingXResultsMessageBuilder>();
            gameDefinitionCreatorMock         = MockRepository.GenerateMock <IGameDefinitionSaver>();
            urlHelperMock          = MockRepository.GenerateMock <UrlHelper>();
            boardGameGeekApiClient = MockRepository.GenerateMock <IBoardGameGeekApiClient>();
            gameDefinitionControllerPartialMock = MockRepository.GeneratePartialMock <GameDefinitionController>(
                dataContextMock,
                gameDefinitionRetrieverMock,
                gameDefinitionTransformationMock,
                showingXResultsMessageBuilderMock,
                gameDefinitionCreatorMock,
                boardGameGeekApiClient);
            gameDefinitionControllerPartialMock.Url = urlHelperMock;

            asyncRequestMock = MockRepository.GenerateMock <HttpRequestBase>();
            asyncRequestMock.Expect(x => x.Headers)
            .Repeat.Any()
            .Return(new System.Net.WebHeaderCollection
            {
                { "X-Requested-With", "XMLHttpRequest" }
            });

            var context = MockRepository.GenerateMock <HttpContextBase>();

            context.Expect(x => x.Request)
            .Repeat.Any()
            .Return(asyncRequestMock);

            gameDefinitionControllerPartialMock.ControllerContext = new ControllerContext(context, new RouteData(), gameDefinitionControllerPartialMock);

            currentUser = new ApplicationUser()
            {
                Id = "user id",
                CurrentGamingGroupId = 15151
            };
        }
コード例 #23
0
        public virtual void SetUp()
        {
            AutomapperConfiguration.Configure();
            autoMocker = new RhinoAutoMocker <PlayerController>();
            autoMocker.PartialMockTheClassUnderTest();
            autoMocker.ClassUnderTest.Url = MockRepository.GenerateMock <UrlHelper>();

            currentUser = new ApplicationUser()
            {
                CurrentGamingGroupId = 123,
                Id = "app user id"
            };

            autoMocker.Get <HttpRequestBase>().Expect(x => x.Headers)
            .Repeat.Any()
            .Return(new System.Net.WebHeaderCollection
            {
                { "X-Requested-With", "XMLHttpRequest" }
            });

            var context = MockRepository.GenerateMock <HttpContextBase>();

            context.Expect(x => x.Request)
            .Repeat.Any()
            .Return(autoMocker.Get <HttpRequestBase>());

            autoMocker.Get <HttpRequestBase>().Expect(mock => mock.Url)
            .Return(new Uri("https://nemestats.com/Details/1"));

            autoMocker.ClassUnderTest.ControllerContext = new ControllerContext(context, new RouteData(), autoMocker.ClassUnderTest);
            autoMocker.Get <IPlayerSummaryBuilder>().Expect(mock => mock.GetTopPlayers(Arg <int> .Is.Anything)).Return(new List <TopPlayer>());
            autoMocker.Get <INemesisHistoryRetriever>().Expect(mock => mock.GetRecentNemesisChanges(Arg <int> .Is.Anything)).Return(new List <NemesisChange>());
            autoMocker.Get <INemesisChangeViewModelBuilder>().Expect(mock => mock.Build(Arg <List <NemesisChange> > .Is.Anything)).Return(new List <NemesisChangeViewModel>());
            autoMocker.ClassUnderTest.Expect(mock => mock.ShowTopPlayers()).Return(new ViewResult {
                ViewName = MVC.Player.Views.TopPlayers, ViewData = new ViewDataDictionary(expectedTopPlayersViewModel)
            });
            autoMocker.ClassUnderTest.Expect(mock => mock.ShowRecentNemesisChanges()).Return(new ViewResult {
                ViewName = MVC.Player.Views.RecentNemesisChanges, ViewData = new ViewDataDictionary(expectedNemesisChangeViewModel)
            });
        }
コード例 #24
0
        public static void RegisterDependencies()
        {
            var builder    = new ContainerBuilder();
            var assemblies = BuildManager.GetReferencedAssemblies().Cast <Assembly>().ToArray();

            builder.RegisterControllers(assemblies);

            builder.RegisterType <LoginClient>()
            .As <ILoginClient>()
            .PreserveExistingDefaults();

            builder.RegisterType <MeasurementClient>()
            .As <IMeasurementClient>()
            .PreserveExistingDefaults();

            builder.Register(c => AutomapperConfiguration.Configure()).As <IMapper>()
            .SingleInstance();

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
コード例 #25
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainWindowVM()
        {
            AutomapperConfiguration.Configure();

            // create the settings for the application
            _Settings = new DefaultAppiumAppSettings();

            // get the appium engine and wire up to it
            _AppiumEngine = AppiumEngine.Instance;
            _AppiumEngine.RunningStatusChanged += _AppiumEngine_RunningStatusChanged;
            _AppiumEngine.OutputDataReceived   += _OutputDataReceived;
            _AppiumEngine.ErrorDataReceived    += _OutputDataReceived;
            _AppiumEngine.Init(_Settings);

            if (_Settings.CheckForUpdates)
            {
                _AppiumEngine.CheckForUpdate();
            }

            _RemoteServerString = GetPropertyName(() => GeneralSettingsVM.UseRemoteServer);
            _UpdateRemoteServerSettings();
            GeneralSettingsVM.PropertyChanged += _GeneralSettingsVM_PropertyChanged;
        }
コード例 #26
0
        public void SetUp()
        {
            autoMocker = new RhinoAutoMocker <UserSessionsController>();

            var dataProtector = MockRepository.GenerateMock <IDataProtector>();

            userStoreMock = MockRepository.GenerateMock <IUserStore <ApplicationUser> >();
            var dataProtectionProvider = MockRepository.GenerateMock <IDataProtectionProvider>();

            dataProtectionProvider.Expect(mock => mock.Create("ASP.N‌​ET Identity")).Return(dataProtector);
            var applicationUserManager = MockRepository.GeneratePartialMock <ApplicationUserManager>(userStoreMock, dataProtectionProvider);

            autoMocker.Inject(applicationUserManager);

            var controllerContextMock = MockRepository.GeneratePartialMock <HttpControllerContext>();
            var actionDescriptorMock  = MockRepository.GenerateMock <HttpActionDescriptor>();

            autoMocker.ClassUnderTest.ActionContext = new HttpActionContext(controllerContextMock, actionDescriptorMock);
            autoMocker.ClassUnderTest.Request       = new HttpRequestMessage();
            autoMocker.ClassUnderTest.Request.SetConfiguration(new HttpConfiguration());

            AutomapperConfiguration.Configure();
        }
コード例 #27
0
ファイル: Startup.cs プロジェクト: w1r2p1/Livescore-Backend
        public void Configuration(IAppBuilder app)
        {
            ConfigureOAuth(app);
            AutomapperConfiguration.Configure();
            Mapper.AssertConfigurationIsValid();
            var builder = new ContainerBuilder();

            HttpConfiguration config = new HttpConfiguration();

            config.Filters.Add(new AuthorizeAttribute());
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            WebApiConfig.Register(config);


            AutofacSetup.RegisterDependencies(ref builder);
            var container = builder.Build();

            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(config);
            app.UseWebApi(config);
        }
コード例 #28
0
        public void TestFixtureSetUp()
        {
            _autoMocker = new RhinoAutoMocker <PlayerDetailsViewModelBuilder>();

            //TODO shouldn't have to do this. Probably need a test base
            AutomapperConfiguration.Configure();

            currentUser = new ApplicationUser()
            {
                CurrentGamingGroupId = gamingGroupId,
                Id = "application user id"
            };

            var gameDefinition1 = new GameDefinition()
            {
                Name = "test game 1",
                Id   = gameDefinitionIdThatIsChampionedByCurrentPlayer,
            };

            gameDefinitionThatIsFormerlyChampionedByCurrentPlayer = new GameDefinition
            {
                Name = "formerly championed game",
                Id   = gameDefinitionIdThatIsFormerlyChampionedByCurrentPlayer
            };
            gameDefinitionThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer = new GameDefinition
            {
                Name = "currently and formerly championed game",
                Id   = gameDefinitionIdThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer
            };
            var playedGame1 = new PlayedGame()
            {
                Id             = 1,
                GameDefinition = gameDefinition1
            };

            var playedGame2 = new PlayedGame()
            {
                Id = 2,
                GameDefinitionId = gameDefinitionIdThatIsFormerlyChampionedByCurrentPlayer
            };
            var playerGameResults = new List <PlayerGameResult>()
            {
                new PlayerGameResult()
                {
                    PlayedGameId = 12, PlayedGame = playedGame1
                },
                new PlayerGameResult()
                {
                    PlayedGameId = 13, PlayedGame = playedGame2
                }
            };

            normalPlayer = new PlayerVersusPlayerStatistics
            {
                OpposingPlayerName                = "Jim",
                OpposingPlayerId                  = 1,
                OpposingPlayerActive              = false,
                NumberOfGamesWonVersusThisPlayer  = 10,
                NumberOfGamesLostVersusThisPlayer = 10
            };

            playerWithNoGamesPlayed = new PlayerVersusPlayerStatistics
            {
                OpposingPlayerId = 2
            };

            minionPlayer = new PlayerVersusPlayerStatistics
            {
                OpposingPlayerName = "Minion Player",
                OpposingPlayerId   = 5,
                NumberOfGamesWonVersusThisPlayer  = 20,
                NumberOfGamesLostVersusThisPlayer = 0
            };

            nemesisPlayer = new PlayerVersusPlayerStatistics
            {
                OpposingPlayerName = "nemesis player",
                OpposingPlayerId   = 3,
                NumberOfGamesWonVersusThisPlayer  = 0,
                NumberOfGamesLostVersusThisPlayer = 100
            };

            previousNemesisPlayer = new PlayerVersusPlayerStatistics

            {
                OpposingPlayerName = "Previous Nemesis Player",
                OpposingPlayerId   = 13,
                NumberOfGamesWonVersusThisPlayer  = 0,
                NumberOfGamesLostVersusThisPlayer = 42
            };

            var nemesis = new Nemesis()
            {
                NemesisPlayerId   = nemesisPlayer.OpposingPlayerId,
                NumberOfGamesLost = 3,
                LossPercentage    = 75,
                NemesisPlayer     = new Player()
                {
                    Name = "Ace Nemesis",
                }
            };

            var previousNemesis = new Nemesis()
            {
                NemesisPlayerId   = previousNemesisPlayer.OpposingPlayerId,
                NumberOfGamesLost = 5,
                LossPercentage    = 66,
                NemesisPlayer     = new Player()
                {
                    Name = "Bravo Nemesis",
                }
            };

            playerDetails = new PlayerDetails()
            {
                Id = playerId,
                ApplicationUserId = currentUser.Id,
                Active            = true,
                Name = "Skipper",
                LongestWinningStreak = 39,
                PlayerGameResults    = playerGameResults,
                PlayerStats          = new PlayerStatistics()
                {
                    TotalGames            = 5,
                    NemePointsSummary     = new NemePointsSummary(1, 3, 5),
                    AveragePlayersPerGame = 3,
                    TotalGamesLost        = 1,
                    TotalGamesWon         = 4,
                    WinPercentage         = 20
                },
                CurrentNemesis  = nemesis,
                PreviousNemesis = previousNemesis,
                Minions         = new List <Player>
                {
                    new Player
                    {
                        Id = minionPlayer.OpposingPlayerId
                    }
                },
                GamingGroupId   = gamingGroupId,
                GamingGroupName = "gaming group name",
                PlayerVersusPlayersStatistics = new List <PlayerVersusPlayerStatistics>
                {
                    normalPlayer,
                    playerWithNoGamesPlayed,
                    nemesisPlayer,
                    previousNemesisPlayer,
                    minionPlayer
                },
                PlayerGameSummaries = new List <PlayerGameSummary>
                {
                    new PlayerGameSummary
                    {
                        GameDefinitionId = gameDefinitionIdThatIsChampionedByCurrentPlayer
                    },
                    new PlayerGameSummary
                    {
                        GameDefinitionId = gameDefinitionIdThatIsFormerlyChampionedByCurrentPlayer
                    },
                    new PlayerGameSummary
                    {
                        GameDefinitionId = gameDefinitionIdThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer
                    }
                },
                NemePointsSummary = new NemePointsSummary(1, 3, 5),
                Achievements      = new List <PlayerAchievementWinner>
                {
                    new PlayerAchievementWinner()
                }
            };

            _autoMocker.Get <IGameResultViewModelBuilder>().Expect(build => build.Build(playerGameResults[0]))
            .Repeat
            .Once()
            .Return(new Models.PlayedGame.GameResultViewModel()
            {
                PlayedGameId = playerGameResults[0].PlayedGameId
            });
            _autoMocker.Get <IGameResultViewModelBuilder>().Expect(build => build.Build(playerGameResults[1]))
            .Repeat
            .Once()
            .Return(new Models.PlayedGame.GameResultViewModel()
            {
                PlayedGameId = playerGameResults[1].PlayedGameId
            });
            foreach (var player in playerDetails.Minions)
            {
                _autoMocker.Get <IMinionViewModelBuilder>().Expect(mock => mock.Build(player))
                .Return(new MinionViewModel()
                {
                    MinionPlayerId = player.Id
                });
            }

            var championedGames = new List <Champion>
            {
                new Champion {
                    GameDefinition = gameDefinition1, GameDefinitionId = gameDefinitionIdThatIsChampionedByCurrentPlayer
                },
                new Champion {
                    GameDefinition = gameDefinitionThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer, GameDefinitionId = gameDefinitionIdThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer
                }
            };

            playerDetails.ChampionedGames = championedGames;

            var formerChampionedGames = new List <GameDefinition>
            {
                gameDefinitionThatIsFormerlyChampionedByCurrentPlayer,
                gameDefinitionThatIsBothCurrentlyAndFormerlyChampionedByCurrentPlayer
            };

            playerDetails.FormerChampionedGames = formerChampionedGames;

            foreach (var achievement in playerDetails.Achievements)
            {
                _autoMocker.Get <ITransformer>()
                .Expect(mock => mock.Transform <PlayerAchievementSummaryViewModel>(achievement))
                .Return(new PlayerAchievementSummaryViewModel());
            }

            playerDetailsViewModel = _autoMocker.ClassUnderTest.Build(playerDetails, twitterMinionBraggingUrl, currentUser);
        }
コード例 #29
0
 public void TestFixtureSetup()
 {
     AutomapperConfiguration.Configure();
 }
コード例 #30
0
 public PersonController()
 {
     AutomapperConfiguration.Configure();
     _personnelModel = new PersonnelModel();
 }