Example #1
0
 public MainWindowViewModel(IJsonRepository jsonRepository, ISqlRepository sqlRepository, IModbusMaster modbusMaster)
 {
     _jsonRepository = jsonRepository ?? throw new ArgumentNullException(nameof(jsonRepository));
     _sqlRepository  = sqlRepository ?? throw new ArgumentNullException(nameof(sqlRepository));
     _modbusMaster   = modbusMaster ?? throw new ArgumentNullException(nameof(modbusMaster));
     StartMethod();
 }
        public async Task Add_IdViolation()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            await Assert.ThrowsAsync <UniquenessConstraintViolationException>(
                () => store.AddAsync(Constants.GetPerson()));
        }
Example #3
0
 /// <summary>
 /// Main facade from API - uses dependency injection in order to load the services and repository
 /// There are 3 endpoints available
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="diffService"></param>
 /// <param name="encodeService"></param>
 /// <param name="logger"></param>
 public DiffController(IJsonRepository repository, IDiffService diffService, IEncodeService encodeService, ILogger <DiffController> logger)
 {
     _jsonRepository = repository;
     _encodeService  = encodeService;
     _diffService    = diffService;
     _logger         = logger;
 }
        public async Task GetAll()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            var persons = await store.GetAllAsync();

            Assert.Contains(Constants.GetPerson(), persons);
        }
Example #5
0
 public ScheduleDataProvider(IJsonParser jsonParser
                             , IJsonRepository jsonRepository
                             , IRESTfulURLProvider urlProvider)
 {
     this.jsonParser     = jsonParser;
     this.jsonRepository = jsonRepository;
     this.urlProvider    = urlProvider;
 }
        public async Task GetById(int id, string expectedName)
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            var person = await store.GetByIdAsync(id);

            Assert.Equal(expectedName, person?.FullName);
        }
        public async Task Exists(int id, bool expected)
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            var idExists = await store.ExistsAsync(id);

            Assert.Equal(expected, idExists);
        }
        public async Task Update_NotExisting()
        {
            IJsonRepository <Person, int> store = GetStore(_options);
            var notExistingItem = new Person {
                Id = 999, FullName = "Nobody"
            };

            await Assert.ThrowsAsync <ItemNotFoundException>(async() => await store.UpdateAsync(notExistingItem));
        }
Example #9
0
        public void TestInitialize()
        {
            this.jsonParser     = new JsonParser();
            this.jsonRepository = new JsonRepository();
            this.urlProvider    = new RESTfulURLProvider();

            this.dataProvider = new ScheduleDataProvider(this.jsonParser
                                                         , this.jsonRepository
                                                         , this.urlProvider
                                                         );
        }
        public async Task Remove_Success()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            await store.RemoveAsync(1);

            await store.SaveChangesAsync();

            IJsonRepository <Person, int> newStore = GetStore(_options);
            var items = await newStore.GetAllAsync();

            Assert.Empty(items);
        }
Example #11
0
        public BooksWorkspaceViewModel(IJsonRepository <BookRecord> bookRepository,
                                       IJsonRepository <AuthorRecord> authorRepository,
                                       IJsonRepository <GenreRecord> genreRepository)
        {
            bookRepository.NullGuard();
            authorRepository.NullGuard();
            genreRepository.NullGuard();

            _bookRepository   = bookRepository;
            _authorRepository = authorRepository;
            _genreRepository  = genreRepository;

            LoadedCommand = AsyncCommandBuilder.Create(LoadBooks);
        }
Example #12
0
        public override void OnFrameworkInitializationCompleted()
        {
            _jsonRepository = new JSonRepository();
            _sqlRepository  = new SqLiteRepository();
            _modbusMaster   = new ModbusRTUMaster();
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                desktop.MainWindow = new MainWindow
                {
                    DataContext = new MainWindowViewModel(_jsonRepository, _sqlRepository, _modbusMaster),
                };
            }

            base.OnFrameworkInitializationCompleted();
        }
        public async Task Add_Success()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            var person2 = Constants.GetPerson2();
            await store.AddAsync(person2);

            await store.SaveChangesAsync();

            // use another repository (without any cache) to load the saved item
            var newRepository = GetStore(_options);
            var items         = (await newRepository.GetAllAsync()).ToList();

            Assert.Contains(person2, items);
            Assert.Equal(2, items.Count);
        }
        public async Task Update_Success()
        {
            IJsonRepository <Person, int> store = GetStore(_options);
            var person = Constants.GetPerson();

            person.FullName = Guid.NewGuid().ToString();

            await store.UpdateAsync(person);

            await store.SaveChangesAsync();

            // reloads the item
            IJsonRepository <Person, int> newStore = GetStore(_options);
            var newPerson = await newStore.GetByIdAsync(person.Id);

            Assert.Equal(person, newPerson);
        }
Example #15
0
        public static async Task <AccountSummaryClass> GetDeserializedClass(
            IJsonRepository jsonNETRepository, int accountNumber)
        {
            var balanceTask = jsonNETRepository.GetBalanceClass(accountNumber);
            var ordersTask  = jsonNETRepository.GetOrdersClass(accountNumber);


            var balance = await balanceTask;
            var orders  = await ordersTask;


            var summary = new AccountSummaryClass()
            {
                Account = accountNumber,
                Balance = balance,
                Orders  = orders
            };

            return(summary);
        }
Example #16
0
        public void GetJsonTest()
        {
            Json[] jsons =
            {
                new Json("{\"key\": \"mock object\"}"),
            };
            Mock <IJsonRepository> mock = new Mock <IJsonRepository>();

            mock.Setup(j => j.GetJson(0)).Returns(jsons[0]);
            mock.Setup(j => j.GetJson(It.Is <int>(i => i <0 && i> jsons.Length))).Returns(new Json(null));
            IJsonRepository iJsonRepo = mock.Object; // используем подставной объект
            // Тест 1
            var actual   = iJsonRepo.GetJson(0);
            var expected = "{\"key\": \"mock object\"}";

            Assert.AreEqual(expected, actual.String, "Ошибка в тесте 1");
            // Тест 2
            actual   = iJsonRepo.GetJson(1);
            expected = null;
            Assert.AreEqual(expected, actual, "Ошибка в тесте 2");
        }
        public async Task SavingEmptyList()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            await Assert.ThrowsAsync <InvalidOperationException>(async() => await store.SaveChangesAsync());
        }
Example #18
0
 public FindJsonInvoker(IJsonRepository repository)
 {
     _repository = repository;
 }
Example #19
0
 public AccountService(IJsonRepository <Account> accountRepository, IJsonRepository <Member> memberRepository)
 {
     _accountRepository = accountRepository;
     _memberRepository  = memberRepository;
 }
Example #20
0
 public void Setup()
 {
     _jsonRepository      = Substitute.For <IJsonRepository>();
     _jsonServiceInstance = new JsonService(_jsonRepository);
 }
Example #21
0
 public JsonService(IJsonRepository jsonRepository, IValidationService validationService)
 {
     JsonRepository    = jsonRepository;
     ValidationService = validationService;
 }
Example #22
0
 public JsonRepositoryTest()
 {
     _jsonRepository = new JsonRepository(DbContext);
 }
Example #23
0
 public PolicyController(IJsonRepository repository, INewsRepository newsRepository, IMapper mapper)
 {
     this.repository     = repository;
     this.newsRepository = newsRepository;
     this.mapper         = mapper;
 }
Example #24
0
 public FileProcessingService(ICsvFileReader csvFileReader, IItemsRepository itemsRepository, IJsonRepository <ItemModel> jsonRepository)
 {
     _csvFileReader   = csvFileReader;
     _itemsRepository = itemsRepository;
     _jsonRepository  = jsonRepository;
 }
 public MemberService(IJsonRepository <Member> memberRepository, MemberValidator membervalidator, IEventPublisher eventPublisher)
 {
     _memberRepository = memberRepository;
     _membervalidator  = membervalidator;
     _eventPublisher   = eventPublisher;
 }
Example #26
0
 public JsonService(IJsonRepository jsonRepository)
 {
     _jsonRepository = jsonRepository;
 }
        public async Task Remove_NotExisting()
        {
            IJsonRepository <Person, int> store = GetStore(_options);

            await Assert.ThrowsAsync <ItemNotFoundException>(async() => await store.RemoveAsync(999));
        }
Example #28
0
 public Distributor(IJsonRepository db)
 {
     this.db = db;
 }
 public InstitutionDataService(IJsonRepository <Institution> institutionRepository)
 {
     _institutionRepository = institutionRepository;
 }
Example #30
0
        private const int NumberOfRowsForTable = 8;  // Per requirements doc every table displaying droplet count from JSON
                                                     // will be organized as 8 x xx
        #endregion

        #region Properties
        #endregion


        #region Ctor

        public JsonDataService(IJsonRepository repository)
        {
            _repository = repository;
        }