public void TestInitialize() { buCategory = new List <CategoryBusinessModel>() { new CategoryBusinessModel() { Description = "Property", Id = 1 } }; buSubCategory = new List <SubCategoryBusinessModel>() { new SubCategoryBusinessModel() { Description = "LDP", Id = 1 } }; buPlatform = new List <PlatformBusinessModel>() { new PlatformBusinessModel() { Description = "iOS", Id = 1 } }; mockCategoryRepository = new Mock <ICategoryRepository>(); mockPlatformRepository = new Mock <IPlatformRepository>(); mockSubCategoryRepository = new Mock <ISubCategoryRepository>(); mockMapper = new Mock <IMapper>(); mockMapper .Setup(x => x.Map <List <CategoryBusinessModel> >(It.IsAny <List <CategoryModel> >())) .Returns(buCategory); mockMapper .Setup(x => x.Map <List <PlatformBusinessModel> >(It.IsAny <List <PlatformModel> >())) .Returns(buPlatform); mockMapper .Setup(x => x.Map <List <SubCategoryBusinessModel> >(It.IsAny <List <SubCategoryModel> >())) .Returns(buSubCategory); mockEntryBusiness = new EntryBusiness( mockCategoryRepository.Object, mockSubCategoryRepository.Object, mockPlatformRepository.Object); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddDbContext <DummyContext>(options => options.UseSqlServer(_configuration.GetConnectionString("DummyContext"))); // Services var localIPv4 = new LocalIPv4(); services.AddSingleton <ILocalIPv4>(localIPv4); var publicIP = new PublicExternalIP(); services.AddSingleton <IPublicIP>(publicIP); var connectionString = (GetEnvConnectionWithLocalMachineIpSubsitution(localIPv4, publicIP) ?? _configuration.GetConnectionString("ConnMsSQL")); Environment.SetEnvironmentVariable("ActualConnectionString", connectionString); var lexiconEntryBusiness = new EntryBusiness( new CategoryRepository(connectionString), new SubCategoryRepository(connectionString), new PlatformRepository(connectionString)); // Repository services.AddSingleton <ICategoryRepository>(new CategoryRepository(connectionString)); services.AddSingleton <ISubCategoryRepository>(new SubCategoryRepository(connectionString)); services.AddSingleton <IPlatformRepository>(new PlatformRepository(connectionString)); services.AddSingleton <IEntryRepository>(new EntryRepository(connectionString)); services.AddSingleton <IEntryPlatformRepository>(new EntryPlatformRepository(connectionString)); // Automagic \ :D / services.AddAutoMapper(x => x.AddProfile(new MappingEntity())); // Business services.AddSingleton <IEntryBusiness>(lexiconEntryBusiness); services.AddSingleton <IViewDataSelectList>(new ViewDataSelectList(lexiconEntryBusiness)); }
public void GetModel_ShouldMapRepository_ToLexiconEntryBusinessModel() { // Arrange var expected = new EntryBusinessModel() { Category = buCategory, SubCategory = buSubCategory }; var classUnderTest = new EntryBusiness( mockCategoryRepository.Object, mockSubCategoryRepository.Object, mockPlatformRepository.Object); // Act var actual = classUnderTest.GetModel(mockMapper.Object); // Assert Assert.AreEqual(expected, actual); }