public void AddBankTest() { var ctx = new StandardListsContext(false); ctx.ClientContext.SiteUsers.AddItem(new UserEmulator() { Login = "******", DisplayName = "Иванов Иван Иванович" }); var currentUser = ctx.ClientContext.EnsureUser("ftc\\testuser"); var bankRepository = new BankRepository(ctx); var httpRepositoryStub = new Mock <IHttpRepository>(); httpRepositoryStub.Setup(m => m.GetCurrentUserLogin()).Returns( "ftc\\testuser" ); var bankService = new BankService(bankRepository, new CurrentUserRepository(httpRepositoryStub.Object, ctx)); bankService.AddBank(new Bank() { Title = "test bank1" }); Assert.IsTrue(ctx.Banks.Count() == 1); }
public CurrentUserRepository( IHttpRepository httpRepository, StandardListsContext ctx) { _ctx = ctx; _httpRepository = httpRepository; }
public void GetAllBanksTest() { var ctx = new StandardListsContext(false); ctx.ClientContext.SiteUsers.AddItem(new UserEmulator() { Login = "******", DisplayName = "Иванов Иван Иванович" }); var authorId = ctx.ClientContext.EnsureUser("ftc\\testuser").Id; ctx.Banks.AddItem( new Bank() { Title = "test1", Author = new SharepointLookupFieldEmulator() { LookupId = authorId } }); var bankRepository = new BankRepository(ctx); // var bankService = new BankService(bankRepository, new HttpRepository()); // Assert.IsTrue(bankService.GetAllBanks().Banks.Count == 1); }
public BankRepository(StandardListsContext ctx) { _ctx = ctx; }