public async Task Should_Get_Cat_By_Id() { var cat = Cats.FirstOrDefault(); var existingCat = await CatRepository.GetByIdAsync(cat.Id); existingCat.Name.Should().Be(cat.Name); }
public async Task GetAll_SpecificCatExists_Successful() { var cat = Cats.FirstOrDefault(); var cats = await CatRepository.GetAll(); cats.FirstOrDefault(x => x.Name == cat.Name).Should().NotBeNull(); }
public CatService(CatRepository repository) { _repository = repository; _mapper = new MapperConfiguration(cfg => { cfg.CreateMap <Cat, CatViewModel>(); }).CreateMapper(); }
public async Task CatById_ForId_Successful() { var cat = TestData.Cats.FirstOrDefault(); var existingCat = await CatRepository.GetById(cat.Id); existingCat.Name.Should().Be(cat.Name); }
public async Task Should_Contain_Specific_Cat() { var cat = Cats.FirstOrDefault(); var cats = await CatRepository.GetAllAsync(); cats.FirstOrDefault(x => x.Name == cat.Name).Should().NotBeNull(); }
public async Task CatBySecondaryId_ForSecondaryId_Successful() { var cat = Cats.FirstOrDefault(); var existingCat = await CatRepository.GetBySecondaryId(cat.SecondaryId); existingCat.Name.Should().Be(cat.Name); }
public CatsViewModel() { Cats = new ObservableCollection <Cat>(); _repository = new CatRepository(); InitializeCommands(); }
public CatViewModel() { catRepo = new CatRepository(); cats = new ObservableCollection <Cat>(); LoadData(); }
public void Setup() { log4net.Config.XmlConfigurator.Configure(); unitOfWorkFactory = ObjectContainer.Get<UnitOfWorkFactory>(); catRepository = ObjectContainer.Get<CatRepository>(); ownerRepository = ObjectContainer.Get<OwnerRepository>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSignalR(); services.AddMvc(options => { var policy = new AuthorizationPolicyBuilder() .RequireAuthenticatedUser() .Build(); options.Filters.Add(new AuthorizeFilter(policy)); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddRazorOptions(options => options.AllowRecompilingViewsOnFileChange = true); 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 .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/Home/Login"; options.LogoutPath = "/Home/Logout"; options.Cookie.Path = "/"; }); var catRepo = new CatRepository(); services.AddSingleton(typeof(IRepository <Cat>), catRepo); services.AddSingleton(typeof(Cache)); if (CurrentEnvironment.IsDevelopment()) { services.AddSwaggerDocument(config => { config.PostProcess = document => { document.Info.Version = "v1"; document.Info.Title = "CATS API"; document.Info.Description = "An API To Manage All Cats Everywhere"; document.Info.Contact = new NSwag.SwaggerContact { Name = "Matthew Fitzpatrick", Email = string.Empty, Url = "https://github.com/thefnordling" }; document.Info.License = new NSwag.SwaggerLicense { Name = "MIT LICENSE", Url = "https://github.com/thefnordling/cats/blob/master/LICENSE" }; }; }); } }
public async Task Create_Cat_Successful() { var cat = new Cat(Guid.NewGuid().ToString(), Ability.Napping); Cats.Add(cat); await CatRepository.Create(cat); var existingCat = await CatRepository.GetById(cat.Id); existingCat.Id.Should().Be(cat.Id); }
public async Task Update_Cat_Successful() { var cat = Cats.FirstOrDefault(); cat.Name = Guid.NewGuid().ToString(); await CatRepository.Update(cat); var existingCat = await CatRepository.GetById(cat.Id); existingCat.Id.Should().Be(cat.Id); }
public async Task Should_Add_A_Cat() { var cat = new Cat { Name = Guid.NewGuid().ToString(), Ability = Ability.Napping }; Cats.Add(cat); await CatRepository.AddAsync(cat); var existingCat = await CatRepository.GetByIdAsync(cat.Id); existingCat.Id.Should().Be(cat.Id); }
public async Task Delete_Cat_Successful() { var cat = TestData.Cats.FirstOrDefault(); cat.Name = Guid.NewGuid().ToString(); await CatRepository.Delete(cat.Id); TestData.Cats.Remove(cat); var existingCat = await CatRepository.GetById(cat.Id); existingCat.Should().BeNull(); }
public BookViewModel() { bookRepo = new BookRepository(); catRepo = new CatRepository(); subCatRepo = new SubCatRepository(); recommendRepo = new RecommendRepository(); books = new ObservableCollection <Book>(); cats = new ObservableCollection <Cat>(); subCats = new ObservableCollection <SubCat>(); recommendList = new ObservableCollection <Recommend>(); paging = new Paging(); pageList = new ObservableCollection <int>(); LoadData(1); }
public async Task Should_Delete_A_Cat() { var cat = Cats.FirstOrDefault(); cat.Name = Guid.NewGuid().ToString(); await CatRepository.DeleteAsync(cat); Cats.Remove(cat); var existingCat = await CatRepository.GetByIdAsync(cat.Id); existingCat.Should().BeNull(); }
private static void InitialiseRepositories() { var sqlConnection = ConfigurationManager.ConnectionStrings["PetAdoptionContextConnection"].ConnectionString; var builder = new DbContextOptionsBuilder <PetAdoptionContext>(); builder.UseSqlServer(sqlConnection); var petAdoptionContext = new PetAdoptionContext(builder.Options); //DbInitialiser.Initialize(petAdoptionContext); _dogRepository = new DogRepository(petAdoptionContext); // new Context.PetAdoptionContext(null, null)); _catRepository = new CatRepository(petAdoptionContext); // new Context.PetAdoptionContext(null, null)); }
public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddJsonOptions(opt => { opt.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); }); var userRepository = new UserRepository(Configuration.GetConnectionString("CatFeedingDB")); var catRepository = new CatRepository(Configuration.GetConnectionString("CatFeedingDB")); var statisticRepository = new StatisticRepository(Configuration.GetConnectionString("CatFeedingDB")); var catSharingRepository = new CatSharingRepository(Configuration.GetConnectionString("CatFeedingDB")); var catFeedingRepository = new CatFeedingRepository(Configuration.GetConnectionString("CatFeedingDB")); var statisticCalculation = new StatisticCalculation(Configuration.GetConnectionString("CatFeedingDB")); services.AddScoped <IUserEntrance>(userEntrance => new UserEntranceProvider(userRepository, new HashWithSaltProtector(10), new Mapper())); services.AddScoped <IUserCRUDService>(userCRUDservice => new UserCRUDService(userRepository, new HashWithSaltProtector(10), new Mapper())); services.AddScoped <IStatisticCalculation>(statistiCalculation => statisticCalculation); services.AddScoped <IStatisticService>(statisticCRUDService => new StatisticService(statisticRepository, statisticCalculation, new Mapper())); services.AddScoped <ICatSharingService>(catSharingService => new CatSharingService(catSharingRepository, catRepository, userRepository, new Mapper())); services.AddScoped <ICatCRUDService>(catCRUDService => new CatCRUDService(catRepository, catSharingRepository, userRepository, new Mapper())); services.AddScoped <ICatFeedingService>(catFeedingService => new CatFeedingService(catFeedingRepository, catRepository, userRepository, catSharingRepository, new Mapper())); services.AddScoped <IServiceResultStatusToResponseConverter>(responseConverter => new ServiceResultCodeToResponseConverter()); services.AddScoped <IMapper>(Mapper => new Mapper()); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = "TaskServer", ValidateAudience = true, ValidAudience = "http://localhost:44338/", ValidateLifetime = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("UNBELIEVABLEsecretKEEEEEYYYYYY!!!!!=)")), ValidateIssuerSigningKey = true, }; }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Tados Test Task", Version = "v1" }); c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); }); }
public CatsController() { catRepository = CatRepository.Instance; }
public CatsController(CatRepository catRepo) { _catRepo = catRepo; }
public async Task Should_Get_Exactly_3_Cats() { var results = await CatRepository.GetAllAsync(); results.Count().Should().BeGreaterThan(0); }
public CatService(CatRepository repository) { _repository = repository; }
public async Task GetAll_Gets3Cats_Successful() { var results = await CatRepository.GetAll(); results.Count().Should().BeGreaterThan(0); }
public CreateModel(CatRepository db) { _db = db; }
public HomeController(BookRepository bookRepo, CatRepository catRepo, SubCatRepository subCatRepo) { this.bookRepo = bookRepo; this.catRepo = catRepo; this.subCatRepo = subCatRepo; }
public CatController() { catsContext = new CatRepository(); }
public CatService(CatRepository repository, MapperConfig mapper) { _repository = repository; _mapper = mapper; }
public MenuViewComponent(CatRepository catRepo) { this.catRepo = catRepo; }
public Service1() { catRepository = new CatRepository(); }
public IHttpActionResult GetCats() { var rrr = new CatRepository(); return(Ok(rrr.Get())); }
public CatController(CatRepository context) { _context = context; }