Beispiel #1
0
        private async Task Login()
        {
            await DialogService.OpenAsync <LoginModal>("Log in to SkyDocs", options : new DialogOptions()
            {
                ShowClose = false, Width = "450px"
            });

            DialogService.Open <LoadingModal>("Loading...", new Dictionary <string, object>()
            {
                { "Msg", $"Loading files from {skyDocsService.CurrentNetwork}..." }
            }, options: new DialogOptions()
            {
                ShowClose = false, ShowTitle = false, Width = "200px"
            });
            await skyDocsService.LoadDocumentList();

            DialogService.Close();
            StateHasChanged();

            if (skyDocsService.IsMetaMaskLogin)
            {
                var address = await MetaMaskService.GetSelectedAddress();

                var shares = await ShareService.GetSharedDocuments(address);

                var myshares = await ShareService.GetDocumentsIShared(address);

                shares = shares.Union(myshares).ToList();

                var shareData = skyDocsService.SetShares(shares);
                Layout.SetNewShares(shareData.total, shareData.newShares);
            }
        }
        public void ShouldNotUpdateShareIfStockDoesntExist()
        {
            // Arrange
            var shareService = new ShareService(
                this.shareRepository,
                this.shareTypeRepository,
                this.stockRepository,
                this.traderRepository);
            ShareInfo shareInfo = new ShareInfo
            {
                Id          = 1,
                Amount      = 2,
                StockId     = 1,
                ShareTypeId = 1,
                OwnerId     = 1
            };
            ShareEntity shareToUpdate = new ShareEntity {
                Id = 1
            };

            this.shareRepository.GetById(1)
            .Returns(shareToUpdate);
            this.stockRepository.GetById(1)
            .ReturnsNull();

            // Act
            shareService.UpdateShare(shareInfo);
        }
Beispiel #3
0
        public async Task <IActionResult> ProcessPayment(Payment payment)
        {
            try
            {
                ShareService shareService = (ShareService)HttpContext.RequestServices.GetService(typeof(ShareService));
                bool         result;
                using (SqlConnection conn = _sqlServer.GetConnection())
                {
                    await conn.OpenAsync();

                    using (SqlTransaction tx = conn.BeginTransaction())
                    {
                        result = await shareService.ProceedPayment(payment, conn, tx);

                        tx.Commit();
                    }
                }

                if (result)
                {
                    return(new JsonResult(payment));
                }
                else
                {
                    return(new JsonErrorResult(
                               new ErrorResponse("payment_exists", "В базе данных существует платёж с такими параметрами (источник данных, номер документа и внешний идентификатор платежа)")));
                }
            }
            catch (Exception ex)
            {
                return(new JsonErrorResult(this.GetExceptionResponse(ex)));
            }
        }
        public void ShouldNotAddNewShareIfShareTypeDoesntExist()
        {
            // Arrange
            var shareService = new ShareService(
                this.shareRepository,
                this.shareTypeRepository,
                this.stockRepository,
                this.traderRepository);
            ShareInfo shareInfo = new ShareInfo
            {
                Amount      = 2,
                StockId     = 1,
                ShareTypeId = 1,
                OwnerId     = 1
            };

            this.stockRepository.GetById(1)
            .Returns(new StockEntity {
            });
            this.traderRepository.GetById(1)
            .ReturnsNull();
            this.shareTypeRepository.GetById(1)
            .ReturnsNull();

            // Act
            shareService.AddNewShare(shareInfo);
        }
        public void ShouldChangeShareType()
        {
            // Arrange
            var shareService = new ShareService(
                this.shareRepository,
                this.shareTypeRepository,
                this.stockRepository,
                this.traderRepository);
            ShareTypeEntity firstShareType = new ShareTypeEntity {
                Id = 1
            };
            ShareTypeEntity secondShareType = new ShareTypeEntity {
                Id = 2
            };
            ShareEntity shareToChange = new ShareEntity {
            };

            this.shareRepository.GetById(Arg.Is <int>(1)).Returns(shareToChange);
            this.shareTypeRepository.GetById(Arg.Is <int>(1)).Returns(firstShareType);
            this.shareTypeRepository.GetById(Arg.Is <int>(2)).Returns(secondShareType);

            // Act
            shareService.ChangeShareType(1, 2);

            // Assert
            this.shareRepository.Received(1).Save(shareToChange);
            Assert.IsTrue(shareToChange.ShareType == secondShareType);
        }
Beispiel #6
0
        public void AccountById_AccountLessThan0_Test()
        {
            // shared service
            var accountRepositoryMock    = new Mock <IAccountRepository>();
            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetAccountById("-1");
        }
Beispiel #7
0
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                CharacterLimit             = int.MaxValue;
                CharactersReservedPerMedia = int.MaxValue;
                IsConfigured = true;
                IsDefault    = false;
                IsImageAttachmentSupported = true;
                Name      = Custom.Resource.ShareTextMessageName;
                Signature = string.Empty;
                UseOAuth  = false;

                ShareService defaultEmail = null;

                lock (Core.Globals.GeneralOptions.ShareServices)
                    defaultEmail = Core.Globals.GeneralOptions.ShareServices.FirstOrDefault(s => s.GetType().Name == "Mail" && s.IsDefault);

                Email       = defaultEmail != null ? defaultEmail.Name : string.Empty;
                MmsAddress  = string.Empty;
                PhoneNumber = 8005551234;
                SmsAddress  = string.Empty;

                PreconfiguredNames = new List <string>
                {
                    Custom.Resource.ShareTextMessagePreconfiguredManual,
                    Custom.Resource.ShareTextMessagePreconfiguredVerizon,
                    Custom.Resource.ShareTextMessagePreconfiguredAtt,
                    Custom.Resource.ShareTextMessagePreconfiguredTMobile,
                    Custom.Resource.ShareTextMessagePreconfiguredSprint
                };

                SelectedPreconfiguredSetting = PreconfiguredNames[0];
            }
        }
Beispiel #8
0
        public void ShouldNotGetShareByIndex()
        {
            // Arrange
            ShareService transactionService = new ShareService(
                this.provider,
                this.shareRep,
                this.traderRep,
                this.logger);

            List <Share> shares = new List <Share>()
            {
                new Share()
                {
                    name     = "Ubisoft",
                    price    = 10m,
                    quantity = 10,
                    ownerId  = 1,
                }
            };

            transactionService.GetShareList("1").Returns(shares);

            // Act
            var result = transactionService.GetShareByIndex(1, 2);
        }
        public void ShouldAddNewShare()
        {
            // Arrange
            var shareService = new ShareService(
                this.shareRepository,
                this.shareTypeRepository,
                this.stockRepository,
                this.traderRepository);
            ShareInfo shareInfo = new ShareInfo
            {
                Amount      = 2,
                StockId     = 1,
                ShareTypeId = 1,
                OwnerId     = 1
            };

            this.shareTypeRepository.GetById(1)
            .Returns(new ShareTypeEntity {
            });
            this.stockRepository.GetById(1)
            .Returns(new StockEntity {
            });
            this.traderRepository.GetById(1)
            .Returns(new TraderEntity {
            });

            // Act
            shareService.AddNewShare(shareInfo);
            // Assert
            this.shareRepository.Received(1).Add(Arg.Any <ShareEntity>());
            this.shareRepository.Received(1).SaveChanges();
        }
Beispiel #10
0
        public async void Returns_Status404NotFound_when_FileNotBelongsToLoggedUser()
        {
            IDatabaseContext databaseContext = DatabaseTestHelper.GetContext();

            MapperConfiguration mapperConfiguration = new MapperConfiguration(conf =>
            {
                conf.AddProfile(new ShareEveryone_to_ShareEveryoneOut());
            });

            IMapper mapper = mapperConfiguration.CreateMapper();

            IShareService shareService = new ShareService(databaseContext, mapper);

            string          ownerUsername = "******";
            ApplicationUser owner         = await databaseContext.Users.FirstOrDefaultAsync(_ => _.UserName == ownerUsername);

            Assert.NotNull(owner);

            File file = new File
            {
                ParentDirectoryID = null,
                Name         = "TestFile.txt",
                OwnerID      = Guid.NewGuid().ToString(),
                ResourceType = DAO.Models.Base.ResourceType.FILE
            };

            await databaseContext.Files.AddAsync(file);

            await databaseContext.SaveChangesAsync();

            StatusCode <ShareEveryoneOut> status = await shareService.ShareForEveryone(file.ID, ownerUsername, null, null, null);

            Assert.NotNull(status);
            Assert.True(status.Code == StatusCodes.Status404NotFound);
        }
Beispiel #11
0
        public void ShouldAddShare()
        {
            // Arrange
            ShareService transactionService = new ShareService(
                this.provider,
                this.shareRep,
                this.traderRep,
                this.logger);

            Trader owner = new Trader()
            {
                name    = "Evgeniy",
                surname = "Nikulin",
            };

            traderRep.GetTrader(Arg.Any <int>()).Returns(owner);

            // Act
            string shareName = "Microsoft";
            string price     = "100";
            string quantity  = "1";
            string ownerId   = "1";

            transactionService.AddShare(shareName, price, quantity, ownerId);

            // Assert
            shareRep.Received(1).Push(Arg.Any <Share>());
            shareRep.Received(1).SaveChanges();
            logger.Info($"{quantity} of {shareName} shares with {price} price is added to {owner.name} {owner.surname} trader");
            provider.Received(1).GetPhrase(Phrase.Success);
        }
Beispiel #12
0
        public void TestCanCreateShare()
        {
            IShare shareservice = new ShareService();
            Share  newshare     = new Share
            {
                ID = Guid.NewGuid(),

                Bady = new Bady {
                    ID = Guid.NewGuid()
                },
                Comment    = "Comment",
                Createby   = "Admin",
                Createtime = DateTime.Now.ToString(),
                IsSuper    = false,
                Keyword    = "Keyword",
                Liked      = 0,
                Link       = "http://www.baidu.com",

                Statues    = 1,
                Updateby   = "Admin",
                Updatetime = DateTime.Now.ToString(),
                UserId     = new Guid("32A2FF15-6AE0-4B7A-8982-C85915738549"),
                Username   = "******"
            };
            Guid id = shareservice.Create(newshare);

            Assert.AreEqual(id, newshare.ID);
        }
Beispiel #13
0
        public void AccountById_AccountMustExist_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(false);
            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();
            var mockMapper            = new Mock <IMapper>();

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetAccountById("27634");
        }
Beispiel #14
0
        public void GetRecordTypes_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);
            var accountIds = new List <int>();

            accountIds.Add(2763);
            accountRepositoryMock.Setup(x => x.GetAllAccountIds(It.IsAny <bool>())).Returns(accountIds);

            var accountEntities = new List <AccountDbO>();

            accountEntities.Add(TestHelper.CreateAccountDbO());
            accountRepositoryMock.Setup(x => x.GetAccountEntities(It.IsAny <bool>())).Returns(accountEntities);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();
            var losRepository            = new Mock <ILosRepository>();

            losRepository.Setup(x => x.GetLosById(It.IsAny <int>())).Returns(new LosDbO {
                LosName = "Encompass"
            });

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();

            recordTypeServiceMock.Setup(x => x.GetListRecordTypeForAccountWithoutValidation(It.IsAny <string>())).Returns(TestHelper.CreateRecordTypes());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <AccountDbO, Api.Service.Models.Response.Account>(It.IsAny <AccountDbO>()))
            .Returns(TestHelper.CreateAccount());

            var accounts = new List <Api.Service.Models.Response.Account>();

            accounts.Add(TestHelper.CreateAccount());

            mockMapper.Setup(x => x.Map <List <AccountDbO>, List <Api.Service.Models.Response.Account> >(It.IsAny <List <AccountDbO> >()))
            .Returns(accounts);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetRecordTypes("2763");

            Assert.AreEqual(result.Count, accountIds.Count);
            Assert.AreEqual(result.ElementAt(0).AccountId, 2763);
            Assert.AreEqual(result.ElementAt(0).Indicator, "C");
            Assert.AreEqual(result.ElementAt(0).Description, "Customers");
        }
Beispiel #15
0
        public async void Returns_False_when_DirectoryIsNotShared()
        {
            IDatabaseContext databaseContext = DatabaseTestHelper.GetContext();

            IShareService   shareService  = new ShareService(databaseContext, null);
            string          ownerUsername = "******";
            ApplicationUser owner         = await databaseContext.Users.FirstOrDefaultAsync(_ => _.UserName == ownerUsername);

            Assert.NotNull(owner);

            Directory directory = new Directory
            {
                ParentDirectoryID = null,
                Name         = "TestDirectory",
                OwnerID      = owner.Id,
                IsShared     = true,
                ResourceType = DAO.Models.Base.ResourceType.DIRECTORY
            };

            await databaseContext.Directories.AddAsync(directory);

            await databaseContext.SaveChangesAsync();

            bool isSharedForEveryone = await shareService.IsSharedForEveryone(directory.ID);

            Assert.False(isSharedForEveryone);
        }
Beispiel #16
0
        public void GetListRecordTypeIdForAccountWithoutValidation_Test()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();

            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeByAccountId(It.IsAny <int>()))
            .Returns(TestHelper.CreateRecordTypeDbOs);

            var losRepository = new Mock <ILosRepository>();

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var mockMapper = new Mock <IMapper>();

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var recordTypeService = new RecordTypeService(recordTypeRepositoryMock.Object, mockMapper.Object, shareService);
            var result            = recordTypeService.GetListRecordTypeIdForAccountWithoutValidation("2763");

            Assert.AreEqual(result.Count, 1);
            Assert.AreEqual(result.ElementAt(0), 19386);
        }
Beispiel #17
0
        public void GetRecordTypeByAccountIdAndId_RecordTypeId_IdExistsButNotInAccount()
        {
            // shared service
            var accountRepositoryMock = new Mock <IAccountRepository>();

            accountRepositoryMock.Setup(x => x.CheckAccountExistsByAcountId(It.IsAny <int>())).Returns(true);
            var accountIds = new List <int>();

            accountIds.Add(2763);
            accountRepositoryMock.Setup(x => x.GetAllAccountIds(It.IsAny <bool>())).Returns(accountIds);

            var accountEntities = new List <AccountDbO>();

            accountEntities.Add(TestHelper.CreateAccountDbO());
            accountRepositoryMock.Setup(x => x.GetAccountEntities(It.IsAny <bool>())).Returns(accountEntities);

            var userRepositoryMock       = new Mock <IUserRepository>();
            var recordTypeRepositoryMock = new Mock <IRecordTypeRepository>();

            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeById(It.IsAny <int>())).Returns(TestHelper.CreateRecordTypeDbO());
            recordTypeRepositoryMock.Setup(x => x.GetRecordTypeByAccountIdAndId(It.IsAny <int>(), It.IsAny <int>())).Returns((RecordTypeDbO)null);

            var losRepository = new Mock <ILosRepository>();

            losRepository.Setup(x => x.GetLosById(It.IsAny <int>())).Returns(new LosDbO {
                LosName = "Encompass"
            });

            // shared service
            var accountValidator              = new AccountRequestDsOValidator(accountRepositoryMock.Object);
            var userValidator                 = new UserRequestDsOValidator(userRepositoryMock.Object);
            var accountUserValidator          = new AccountUserRequestDsoValidator(userRepositoryMock.Object);
            var recordTypeRequestDsOValidator = new RecordTypeRequestDsOValidator(recordTypeRepositoryMock.Object);
            var accountRecordTypeDsOValidator = new AccountRecordTypeDsOValidator(recordTypeRepositoryMock.Object);

            // account Service
            var recordTypeServiceMock = new Mock <IRecordTypeService>();

            recordTypeServiceMock.Setup(x => x.GetListRecordTypeIdForAccountWithoutValidation(It.IsAny <string>())).Returns(TestHelper.CreateRecordTypeIds());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <AccountDbO, Api.Service.Models.Response.Account>(It.IsAny <AccountDbO>()))
            .Returns(TestHelper.CreateAccount());

            var accounts = new List <Api.Service.Models.Response.Account>();

            accounts.Add(TestHelper.CreateAccount());

            mockMapper.Setup(x => x.Map <List <AccountDbO>, List <Api.Service.Models.Response.Account> >(It.IsAny <List <AccountDbO> >()))
            .Returns(accounts);

            var shareService = new ShareService(accountValidator, userValidator, accountUserValidator, recordTypeRequestDsOValidator, accountRecordTypeDsOValidator, losRepository.Object);

            var accountService = new AccountService(shareService, accountRepositoryMock.Object, mockMapper.Object,
                                                    recordTypeServiceMock.Object);

            var result = accountService.GetRecordTypeByAccountIdAndId(It.IsAny <string>(), "27634");
        }
        public JsonResult shareSave(T_SHARE list)
        {
            RTN_SAVE_DATA rtn = new ShareService().ShareSave(list);

            return(new JsonResult {
                Data = rtn
            });
        }
Beispiel #19
0
        public async override Task OnShare(string text, string imageFilePath)
        {
            ShareService mailService = null;

            lock (Core.Globals.GeneralOptions.ShareServices)
                mailService = Core.Globals.GeneralOptions.ShareServices.FirstOrDefault(s => s.GetType().Name == "Mail" && s.Name == Email);
            if (mailService == null)
            {
                LogAndPrint(typeof(Custom.Resource), "ShareTextMessageUnknownEmailService", new[] { Email }, Cbi.LogLevel.Error);
                return;
            }

            string address = string.Empty;

            if (!string.IsNullOrEmpty(SmsAddress) && string.IsNullOrEmpty(MmsAddress))
            {
                address = PhoneNumber.ToString(CultureInfo.InvariantCulture) + SmsAddress;
            }
            else if (string.IsNullOrEmpty(SmsAddress) && !string.IsNullOrEmpty(MmsAddress))
            {
                address = PhoneNumber.ToString(CultureInfo.InvariantCulture) + MmsAddress;
            }
            else if (!string.IsNullOrEmpty(SmsAddress) && !string.IsNullOrEmpty(MmsAddress))
            {
                if (string.IsNullOrEmpty(imageFilePath))
                {
                    address = PhoneNumber.ToString(CultureInfo.InvariantCulture) + SmsAddress;
                }
                else
                {
                    address = PhoneNumber.ToString(CultureInfo.InvariantCulture) + MmsAddress;
                }
            }

            ShareService liveClone = mailService.Clone() as ShareService;

            try
            {
                if (liveClone != null)
                {
                    liveClone.SetState(State.Active);
                    await liveClone.OnShare(text, imageFilePath, new[] { address, string.Empty });

                    LogAndPrint(typeof(Custom.Resource), "ShareTextMessageSentSuccessfully", new[] { Name }, Cbi.LogLevel.Information);
                }
            }
            catch (Exception exp)
            {
                LogAndPrint(typeof(Custom.Resource), "ShareTextMessageErrorOnShare", new [] { liveClone.Name, exp.Message }, Cbi.LogLevel.Error);
            }
            finally
            {
                if (liveClone != null)
                {
                    liveClone.SetState(State.Finalized);
                }
            }
        }
        private async void OnShareImage()
        {
            _image = await GetImage();

            if (_image != null)
            {
                ShareService.ShareImage(_image, "Share image", "We are sharing an image");
            }
        }
        private async void OnShareDeferralImage()
        {
            _image = await GetImage();

            if (_image != null)
            {
                ShareService.ShareDeferredContent(StandardDataFormats.Bitmap, GetDeferredImageAsync, "Share image", "We are sharing an image");
            }
        }
Beispiel #22
0
 ShareController() : base()
 {
     _service            = new ShareService();
     _client             = new HttpClient();
     _client.BaseAddress = new Uri("https://localhost:44309/api/");
     _client.DefaultRequestHeaders.Accept.Clear();
     _client.DefaultRequestHeaders.Accept.Add(
         new MediaTypeWithQualityHeaderValue("application/json"));
 }
Beispiel #23
0
        private void SetShareUrl(bool readOnly)
        {
            var sum = SkyDocsService.CurrentSum;

            if (sum != null)
            {
                ShareService.CurrentShareUrl = ShareService.GetShareUrl(sum, readOnly);
            }
        }
        public Result <IList <Shares> > GetAll(int plannerId)
        {
            var          result       = new Result <IList <Shares> >();
            ShareService shareService = new ShareService();

            result.Value     = shareService.GetAll(plannerId);
            result.IsSuccess = true;
            return(result);
        }
Beispiel #25
0
        public void ShouldNotChangeShareTypeIfShareDoesntExist()
        {
            // Arrange
            var shareService = new ShareService(this.shareRepository, this.shareTypeRepository);

            this.shareRepository.GetById(Arg.Is <int>(1)).ReturnsNull();

            // Act
            shareService.ChangeShareType(1, 1);
        }
        public TradeSimulator(IValidator validator, ILogger logger, ClientService clientService, ShareService shareService, TradingOperationService tradingOperationService)
        {
            this.clientService           = clientService;
            this.shareService            = shareService;
            this.validator               = validator;
            this.logger                  = logger;
            this.tradingOperationService = tradingOperationService;

            logger.InitLogger();
            uniformRandomiser = new Random();
        }
        public void ShouldGetAllShares()
        {
            //Arrange
            ShareService shareService = new ShareService(shareRepository);
            //Act
            var shares = shareService.GetAllShares();

            //Assert
            shareRepository.Received(1).LoadAllShares();
            Assert.AreEqual(3, shares.Count());
        }
Beispiel #28
0
 public void OnShare()
 {
     if (skyDocsService.CurrentDocument != null && skyDocsService.CurrentSum != null)
     {
         ShareService.CurrentShareUrl = ShareService.GetShareUrl(skyDocsService.CurrentSum, true);
         DialogService.Open <ShareModal>("Share document", options: new DialogOptions()
         {
             ShowClose = true
         });
     }
 }
Beispiel #29
0
        public void Share_FileProcessed(SharedFile file, object arg)
        {
            ulong user = (ulong)arg;

            ShareService share = Core.GetService(ServiceIDs.Share) as ShareService;

            string message = "File: " + file.Name +
                             ", Size: " + Utilities.ByteSizetoDecString(file.Size) +
                             ", Download: " + share.GetFileLink(Core.UserID, file);

            SendMessage(user, message, TextFormat.Plain);
        }
Beispiel #30
0
        public void ShouldReturnSharesForExactId()
        {
            // Arrange
            var shareService = new ShareService(this.shareRepository, this.shareTypeRepository);

            // Act
            var tradersShares = shareService.GetAllSharesByTraderId(1);

            // Assert
            shareRepository.Received(2).GetAll();
            Assert.IsFalse(tradersShares.Any(s => s.Owner.Id != 1));
        }