Example #1
0
 public DefaultController(IVolunteerService volunteerService, ICatService catService, IDogService dogService, IAdopterService adopterService)
 {
     this.volunteerService = volunteerService;
     this.catService       = catService;
     this.dogService       = dogService;
     this.adopterService   = adopterService;
 }
Example #2
0
 public FooTrioConstructor(IFooService foo, IBarService bar, ICatService cat)
 {
     Foo    = foo;
     Bar    = bar;
     Cat    = cat;
     Option = "(Foo, Bar, Cat)";
 }
Example #3
0
 public App(ILogger <App> logger, ICatService catService, TextWriter outputWriter, TextReader inputReader)
 {
     this.logger       = logger ?? throw new ArgumentNullException(nameof(logger));
     this.catService   = catService ?? throw new ArgumentNullException(nameof(catService));
     this.outputWriter = outputWriter ?? throw new ArgumentNullException(nameof(outputWriter));
     this.inputReader  = inputReader ?? throw new ArgumentNullException(nameof(inputReader));
 }
 public CatsController(
     ICatService cats,
     ICurrentUserService currentUser)
 {
     this.cats        = cats;
     this.currentUser = currentUser;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CatsController"/> class.
 /// </summary>
 /// <param name="catService"></param>
 /// <param name="fileService"></param>
 /// <param name="logger"></param>
 /// <param name="env"></param>
 /// <param name="settings"></param>
 public CatsController(ICatService catService, IFileService fileService, ILogger <CatsController> logger, IHostingEnvironment env, IOptions <ApplicationOptions> settings)
 {
     _catService         = catService ?? throw new ArgumentNullException(nameof(catService));
     _fileService        = fileService ?? throw new ArgumentNullException(nameof(fileService));
     _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     ApplicationSettings = settings.Value;
     _env = env;
 }
Example #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CatsControllerV2"/> class.
        /// </summary>
        /// <param name="catService">Cat Service</param>
        /// <param name="fileService">File Service</param>
        /// <param name="logger">Logger</param>
        /// <param name="settings"></param>
        public CatsControllerV2(ICatService catService, IFileService fileService, ILogger <CatsControllerV2> logger, IOptions <ApplicationOptions> settings)
        {
            _catService         = catService ?? throw new ArgumentNullException(nameof(catService));
            _logger             = logger ?? throw new ArgumentNullException(nameof(logger));
            _fileService        = fileService ?? throw new ArgumentNullException(nameof(fileService));
            ApplicationSettings = settings.Value;

            _logger.LogInformation("Init CatsControllerV2-1: {Now}", DateTime.Now);
        }
Example #7
0
        public void SetupForEachTest()
        {
            var options = new DbContextOptionsBuilder <AppDbContext>()
                          .UseInMemoryDatabase(databaseName: "CatsDatabase")
                          .Options;
            var context = new AppDbContext(options);

            _catService = new CatService(context);
        }
        public CatListPageViewModel(INavigationService navigationService,
                                    IPageDialogService pageDialogService,
                                    IDeviceService deviceService,
                                    ICatService catService) : base(navigationService, pageDialogService, deviceService)
        {
            _catService = catService;

            Cats = new ObservableCollection <Cat>();
        }
Example #9
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <AppDbContext>()
                          .UseInMemoryDatabase(databaseName: "CatsDatabase2")
                          .Options;
            var context = new AppDbContext(options);

            _populateBDD = new PopulateBDDService(context, _filePath);
            _catService  = new CatService(context);
        }
        public void Given_NullParameter_Constructor_ShouldThrow_ArgumentNullException()
        {
            // Arrange
            ICatService catService = null;

            // Action
            Action action = () => { new CatsController(catService, null, null, null, null); };

            // Assert
            action.Should().Throw <ArgumentNullException>();
        }
        public void OneTimeSetUp()
        {
            Setup.Bootstrap(SetupType.Test);

            CreateCatTestData();

            var mockApiClient  = new Mock <IApiClient>();
            var mockServiceBus = new Mock <IMessageBroker <Cat> >();
            var mockCatService = new Mock <ICatService>();

            // Setup the cat service
            mockCatService.Setup(x => x.GetAll()).Returns(Task.FromResult(Cats.AsEnumerable()));

            mockCatService.Setup(x => x.GetById(It.IsAny <Guid>()))
            .Returns((Guid id) => { return(Task.FromResult(Cats.FirstOrDefault(x => x.Id == id))); });

            mockCatService.Setup(x => x.Create(It.IsAny <Cat>()))
            .Returns((Cat entity) =>
            {
                Cats.Add(entity);

                return(Task.CompletedTask);
            });

            mockCatService.Setup(x => x.Update(It.IsAny <Cat>()))
            .Returns((Cat entity) =>
            {
                var existing = Cats.Find(x => x.Id == entity.Id);

                Cats.Remove(existing);
                Cats.Add(entity);

                return(Task.CompletedTask);
            });

            mockCatService.Setup(x => x.Delete(It.IsAny <Guid>()))
            .Returns((Guid id) =>
            {
                Cats.Remove(Cats.FirstOrDefault(x => x.Id == id));
                return(Task.CompletedTask);
            });

            ApiClient     = mockApiClient.Object;
            MessageBroker = mockServiceBus.Object;
            CatService    = mockCatService.Object;

            ViewModel = new MainViewModel(CatService);
        }
        private CatsController GetCatsController(
            ICatService catService                 = null,
            IFileService fileService               = null,
            ILogger <CatsController> logger        = null,
            IOptions <ApplicationOptions> settings = null
            )
        {
            catService  = catService ?? new Mock <ICatService>().Object;
            fileService = fileService ?? new Mock <IFileService>().Object;
            logger      = logger ?? new Mock <ILogger <CatsController> >().Object;

            var env = new Mock <IHostingEnvironment>();

            env.Setup(m => m.ContentRootPath).Returns("/");

            settings = settings ?? _serviceProvider.GetService <IOptions <ApplicationOptions> >();

            return(new CatsController(catService, fileService, logger, env.Object, settings));
        }
Example #13
0
        private CatsControllerV2 GetCatsControllerV2(
            HttpResponseMessage responseMessage,
            ICatService catService                 = null,
            IFileService fileService               = null,
            ILogger <CatsControllerV2> logger      = null,
            IOptions <ApplicationOptions> settings = null)
        {
            catService ??= new Mock <ICatService>().Object;
            fileService ??= new Mock <IFileService>().Object;
            logger ??= new Mock <ILogger <CatsControllerV2> >().Object;

            var env = new Mock <IWebHostEnvironment>();

            env.Setup(m => m.ContentRootPath).Returns("/");

            settings ??= _serviceProvider.GetService <IOptions <ApplicationOptions> >();
            responseMessage.Headers.Add("x-inlinecount", "10");

            logger ??= new Mock <ILogger <CatsControllerV2> >().Object;
            return(new CatsControllerV2(catService, fileService, logger, settings));
        }
        public CatServiceMock()
        {
            var mockCatService = new Mock <ICatService>();

            // Setup the cat service
            mockCatService.Setup(x => x.GetAll()).Returns(Task.FromResult(TestData.Cats.AsEnumerable())).Verifiable();

            mockCatService.Setup(x => x.GetById(It.IsAny <Guid>()))
            .Returns((Guid id) => { return(Task.FromResult(TestData.Cats.FirstOrDefault(x => x.Id == id))); })
            .Verifiable();

            mockCatService.Setup(x => x.Create(It.IsAny <Cat>()))
            .Returns((Cat entity) =>
            {
                TestData.Cats.Add(entity);

                return(Task.CompletedTask);
            }).Verifiable();

            mockCatService.Setup(x => x.Update(It.IsAny <Cat>()))
            .Returns((Cat entity) =>
            {
                var existing = TestData.Cats.Find(x => x.Id == entity.Id);

                TestData.Cats.Remove(existing);
                TestData.Cats.Add(entity);

                return(Task.CompletedTask);
            }).Verifiable();

            mockCatService.Setup(x => x.Delete(It.IsAny <Guid>()))
            .Returns((Guid id) =>
            {
                TestData.Cats.Remove(TestData.Cats.FirstOrDefault(x => x.Id == id));

                return(Task.CompletedTask);
            }).Verifiable();

            Instance = mockCatService.Object;
        }
Example #15
0
 public CatsController(ICatService catService)
 {
     this.catService = catService;
 }
Example #16
0
 public void Initialize()
 {
     catService = new CatService(repositoryMock.Object, dateProviderMock.Object);
     dateProviderMock.Setup(x => x.GetCurrentDate()).Returns(new DateTime(2020, 8, 30));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CatsControllerV2"/> class.
 /// </summary>
 /// <param name="catService"></param>
 /// <param name="logger"></param>
 public CatsControllerV2(ICatService catService, ILogger <CatsControllerV2> logger)
 {
     _catService = catService ?? throw new ArgumentNullException(nameof(catService));
     _logger     = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Example #18
0
 public CatCliCommand(ICatService service)
 {
     this._service = service;
 }
 /// <summary>
 /// Cats Controller Constructor
 /// </summary>
 /// <param name="catService">Cat Service</param>
 public CatsControlller(ICatService catService)
 {
     _catService = catService;
 }
Example #20
0
 public CatModule(ICatService catService)
 {
     this.catService = catService;
 }
Example #21
0
 public CatsServiceController(ICatService cats)
 => this.cats = cats;
Example #22
0
 public CatsController(ICatService catService, IMapper mapper)
 {
     this.catService = catService;
     this.mapper     = mapper;
 }
Example #23
0
 public HomeController(ICatService catService)
 {
     this.catService = catService;
 }
Example #24
0
        private CatsControllerV2 GetCatsControllerV2(HttpResponseMessage responseMessage, ICatService catService = null, ILogger <CatsControllerV2> logger = null)
        {
            catService = catService ?? new Mock <ICatService>().Object;

            // TODO - Add to Helper
            responseMessage.Headers.Add("x-inlinecount", "10");

            logger = logger ?? new Mock <ILogger <CatsControllerV2> >().Object;
            return(new CatsControllerV2(catService, logger));
        }
Example #25
0
 public CatsController(ICatService cats)
 {
     this.cats = cats;
 }
Example #26
0
 public PetController(ICatService services)
 {
     _catService = services;
 }
Example #27
0
 public CatsController(ICatService customerService, IUnitOfWorkAsync unitOfWorkAsync)
 {
     _customerService = customerService;
     _unitOfWorkAsync = unitOfWorkAsync;
 }
Example #28
0
 public CatController(ILogger <CatController> logger, ICatService catService)
 {
     _logger     = logger;
     _catService = catService;
 }
 public CatModule(ICatService catService) => _catService = catService;
Example #30
0
 public CatServiceTest(CatServiceFixture fixture, ITestOutputHelper output)
 {
     this._catService = fixture.CatService;
     this._output     = output;
 }