Exemple #1
0
 public StartupChainModule(Context context, ChainService chainSyncService, NodeConnectionService nodeConnectionService, ILoggerFactory loggerFactory) : base(context)
 {
     this.ChainIndex            = context.ChainIndex;
     this.chainSyncService      = chainSyncService;
     this.nodeConnectionService = nodeConnectionService;
     this.logger = loggerFactory.CreateLogger <StartupChainModule>();
 }
Exemple #2
0
        public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse()
        {
            var mock          = new ServiceMockFacade <IChainService, IChainRepository>();
            var model         = new ApiChainServerRequestModel();
            var validatorMock = new Mock <IApiChainServerRequestModelValidator>();

            validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>()
            {
                new ValidationFailure("text", "test")
            })));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           validatorMock.Object,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeFalse();
            validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <ChainDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never());
        }
Exemple #3
0
 public ShutdowhainChainModule(Context context, ChainService chainSyncService, NodeConnectionService nodeConnectionService, ILoggerFactory loggerFactory, WalletStore walletStore) : base(context)
 {
     this.ChainIndex            = context.ChainIndex;
     this.chainSyncService      = chainSyncService;
     this.nodeConnectionService = nodeConnectionService;
     this.walletStore           = walletStore;
     this.logger = loggerFactory.CreateLogger <ShutdowhainChainModule>();
 }
Exemple #4
0
        private void Load_Data()
        {
            ChainService chainService = new ChainService();

            ChainDropdown.ItemsSource       = chainService.GetAll();
            ChainDropdown.SelectedValuePath = "Id";
            ChainDropdown.DisplayMemberPath = "Name";
        }
 public ReadController(BaseSimpleControllerServices services, ILanguageService docService, ChainService service,
                       RelationListenerService relationListenerService, IMapper mapper, ChainServiceConfig serviceConfig)
     : base(services)
 {
     this.docService = docService;
     this.service    = service;
     this.relationListenerService = relationListenerService;
     this.mapper        = mapper;
     this.serviceConfig = serviceConfig;
 }
Exemple #6
0
 public Logger(Context context, ILoggerFactory loggerFactory, LogFilter logFilter, WalletStore walletStore,
               WalletService walletService, BlockMiner blockMiner, ChainService chainService, NodeConnectionService nodeConnectionService, MinerService minerService) : base(context)
 {
     this.context               = context;
     this.logFilter             = logFilter;
     this.walletStore           = walletStore;
     this.walletService         = walletService;
     this.blockMiner            = blockMiner;
     this.chainService          = chainService;
     this.nodeConnectionService = nodeConnectionService;
     this.minerService          = minerService;
     this.logger = loggerFactory.CreateLogger <Staker>();
 }
 public ReadController(BaseSimpleControllerServices services, ILanguageService docService, ChainService service,
                       RelationListenerService relationListenerService, IMapper mapper, ChainServiceConfig serviceConfig,
                       ITempTokenService <long> tokenService, Action <Newtonsoft.Json.JsonSerializerSettings> jsonOptionAction)
     : base(services)
 {
     this.docService = docService;
     this.service    = service;
     this.relationListenerService = relationListenerService;
     this.mapper           = mapper;
     this.serviceConfig    = serviceConfig;
     this.tokenService     = tokenService;
     this.jsonOptionAction = jsonOptionAction;
 }
Exemple #8
0
        //[Fact]
        public void DeployTestChain()
        {
            var arg = new DeployArg();

            arg.AccountPassword         = "******";
            arg.DBArg                   = new DeployDBArg();
            arg.LighthouseArg           = new DeployLighthouseArg();
            arg.LighthouseArg.IsCluster = false;
            arg.WorkArg                 = new DeployWorkArg();
            arg.LauncherArg             = new DeployLauncherArg();
            arg.LauncherArg.IsConsensusInfoGenerator = true;

            var service = new ChainService();

            service.DeployMainChain(arg);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // validate input
            string error = "";

            if (ChainNameTextBox.Text == "")
            {
                error += "Fill in Chain name.\n";
            }
            if (LogoLinkTextBox.Text == "")
            {
                error += "Fill in the logo's link.\n";
            }
            if (error != "")
            {
                MessageBox.Show(error);
            }
            else
            {
                ChainService chainService = new ChainService();
                try
                {
                    // create and send dto
                    ChainDto chainDto = new ChainDto
                    {
                        Name = ChainNameTextBox.Text,
                        Logo = LogoLinkTextBox.Text
                    };
                    if (APIdropdown.SelectedIndex >= 0)
                    {
                        chainDto.ShopApi_Id = (int)APIdropdown.SelectedValue;
                    }
                    chainService.Create(chainDto);
                    MessageBox.Show("Chain was successfully created!");
                    // reset form
                    ChainNameTextBox.Text     = "";
                    LogoLinkTextBox.Text      = "";
                    APIdropdown.SelectedIndex = -1;
                }
                catch
                {
                    MessageBox.Show("Failed to add a chain.");
                }
            }
        }
Exemple #10
0
        public async void ByExternalId_Not_Exists()
        {
            var mock = new ServiceMockFacade <IChainService, IChainRepository>();

            mock.RepositoryMock.Setup(x => x.ByExternalId(It.IsAny <Guid>())).Returns(Task.FromResult <Chain>(null));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            ApiChainServerResponseModel response = await service.ByExternalId(default(Guid));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.ByExternalId(It.IsAny <Guid>()));
        }
Exemple #11
0
        public async void LinksByChainId_Not_Exists()
        {
            var mock = new ServiceMockFacade <IChainService, IChainRepository>();

            mock.RepositoryMock.Setup(x => x.LinksByChainId(default(int), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult <List <Link> >(new List <Link>()));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            List <ApiLinkServerResponseModel> response = await service.LinksByChainId(default(int));

            response.Should().BeEmpty();
            mock.RepositoryMock.Verify(x => x.LinksByChainId(default(int), It.IsAny <int>(), It.IsAny <int>()));
        }
Exemple #12
0
        public async void Get_ShouldReturnNullBecauseRecordNotFound()
        {
            var mock = new ServiceMockFacade <IChainService, IChainRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <Chain>(null));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            ApiChainServerResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Exemple #13
0
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IChainRepository>();
            var record = new Chain();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(record));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLChainMapperMock,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.BOLMapperMockFactory.BOLLinkMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            ApiChainResponseModel response = await service.Get(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
Exemple #14
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IChainRepository>();
            var model = new ApiChainRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Chain>())).Returns(Task.FromResult(new Chain()));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLChainMapperMock,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.BOLMapperMockFactory.BOLLinkMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            CreateResponse <ApiChainResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.ChainModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiChainRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Chain>()));
        }
Exemple #15
0
        public async void All_ShouldReturnRecords()
        {
            var mock    = new ServiceMockFacade <IChainService, IChainRepository>();
            var records = new List <Chain>();

            records.Add(new Chain());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(records));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            List <ApiChainServerResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()));
        }
Exemple #16
0
        public async void Delete()
        {
            var mock  = new ServiceMockFacade <IChainRepository>();
            var model = new ApiChainRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.BOLMapperMockFactory.BOLChainMapperMock,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.BOLMapperMockFactory.BOLLinkMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.ChainModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
        }
Exemple #17
0
        public async void ClaspsByPreviousChainId_Exists()
        {
            var mock    = new ServiceMockFacade <IChainService, IChainRepository>();
            var records = new List <Clasp>();

            records.Add(new Clasp());
            mock.RepositoryMock.Setup(x => x.ClaspsByPreviousChainId(default(int), It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            List <ApiClaspServerResponseModel> response = await service.ClaspsByPreviousChainId(default(int));

            response.Should().NotBeEmpty();
            mock.RepositoryMock.Verify(x => x.ClaspsByPreviousChainId(default(int), It.IsAny <int>(), It.IsAny <int>()));
        }
Exemple #18
0
        public async void Delete_NoErrorsOccurred_ShouldReturnResponse()
        {
            var mock  = new ServiceMockFacade <IChainService, IChainRepository>();
            var model = new ApiChainServerRequestModel();

            mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask);
            var service = new ChainService(mock.LoggerMock.Object,
                                           mock.MediatorMock.Object,
                                           mock.RepositoryMock.Object,
                                           mock.ModelValidatorMockFactory.ChainModelValidatorMock.Object,
                                           mock.DALMapperMockFactory.DALChainMapperMock,
                                           mock.DALMapperMockFactory.DALClaspMapperMock,
                                           mock.DALMapperMockFactory.DALLinkMapperMock);

            ActionResponse response = await service.Delete(default(int));

            response.Should().NotBeNull();
            response.Success.Should().BeTrue();
            mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>()));
            mock.ModelValidatorMockFactory.ChainModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>()));
            mock.MediatorMock.Verify(x => x.Publish(It.IsAny <ChainDeletedNotification>(), It.IsAny <CancellationToken>()));
        }
 public ReadTestListen() : base()
 {
     chainer = CreateService <ChainService>(true);
 }
Exemple #20
0
        public void Load_Data()
        {
            ChainService chainService = new ChainService();

            ChainData.ItemsSource = chainService.GetAll();
        }
Exemple #21
0
 public ChainController(ChainService service)
 {
     _service = service;
 }
Exemple #22
0
        //[Fact]
        public void RemoveTestChain()
        {
            var service = new ChainService();

            service.RemoveMainChain(chainId);
        }