本文整理汇总了C#中FakeRepository.Add方法的典型用法代码示例。如果您正苦于以下问题:C# FakeRepository.Add方法的具体用法?C# FakeRepository.Add怎么用?C# FakeRepository.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FakeRepository
的用法示例。
在下文中一共展示了FakeRepository.Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRequest_GetAllTest_NoCategories
public void GetRequest_GetAllTest_NoCategories()
{
FakeRepository<Category> categoryFakeRepository = new FakeRepository<Category>();
FakeRepository<User> userFakeRepository = new FakeRepository<User>();
FakeRepository<Thread> threadFakeRepository = new FakeRepository<Thread>();
string sessionKey = "01234567890123456789012345678901234567890123456789";
User user = new User()
{
SessionKey = sessionKey
};
userFakeRepository.Add(user);
CategoriesController categoriesController = new CategoriesController(
categoryFakeRepository, userFakeRepository, threadFakeRepository);
SetupController(categoriesController);
var allCategories = categoriesController.GetAll(sessionKey).ToList<string>();
int expectedCategoryCount = 0;
Assert.AreEqual(expectedCategoryCount, allCategories.Count);
}
示例2: Initialize
public void Initialize()
{
_warehouses = new FakeRepository<Warehouse>();
_warehouse1 = new Warehouse { Name = "Hanger 18" };
_procrit = new Product { Id = 11190 };
_warehouse1.Requisitions = new List<Requisition>();
_warehouse1.Requisitions.Add(new Requisition
{
Product = _procrit,
Quantity = 7,
Restocks = new List<Restock> { new Restock() }
});
_warehouse1.PickLists = new List<PickList>();
_warehouses.Add(_warehouse1);
_clinic = new Customer
{
Name = "The Clinic",
ShippingAddress = "1 My Way"
};
_service = new InventoryAllocationService(_warehouses);
}
示例3: Add_ValidStudent_ShouldBeAddedToDb
public void Add_ValidStudent_ShouldBeAddedToDb()
{
var repository = new FakeRepository();
var student = new Student()
{
StudentId = 1,
FirstName = "Gosho",
LastName = "Peshev",
Age = 12,
Grade = 5
};
student.School = new School() { SchoolId = 1, Name = "test school", Location = "Burgas" };
student.Marks.Add(new Mark() { MarkId = 1, Subject = "physics", Value = "4" });
repository.Add(student);
var controller = new StudentsController(repository);
SetupController(controller);
var allStudents = controller.GetAll();
Assert.IsTrue(allStudents.Count() == 1);
Assert.AreEqual(student.LastName, allStudents.First().LastName);
}
示例4: PostRequest_CreateCategoryTest_SuccessfulCreation
public void PostRequest_CreateCategoryTest_SuccessfulCreation()
{
FakeRepository<Category> categoryFakeRepository = new FakeRepository<Category>();
FakeRepository<User> userFakeRepository = new FakeRepository<User>();
FakeRepository<Thread> threadFakeRepository = new FakeRepository<Thread>();
string sessionKey = "01234567890123456789012345678901234567890123456789";
CategoryModel categoryModel = new CategoryModel()
{
Name = "Test category"
};
User user = new User()
{
SessionKey = sessionKey
};
userFakeRepository.Add(user);
CategoriesController categoriesController = new CategoriesController(
categoryFakeRepository, userFakeRepository, threadFakeRepository);
SetupController(categoriesController);
var response = categoriesController.CreateCategory(categoryModel, sessionKey);
int expectedCategoryCount = 1;
Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
Assert.AreEqual(expectedCategoryCount, categoryFakeRepository.entities.Count);
}
示例5: PostRequest_CreateCategoryTest_InvalidCreation_CannotAddNullCategory
public void PostRequest_CreateCategoryTest_InvalidCreation_CannotAddNullCategory()
{
FakeRepository<Category> categoryFakeRepository = new FakeRepository<Category>();
FakeRepository<User> userFakeRepository = new FakeRepository<User>();
FakeRepository<Thread> threadFakeRepository = new FakeRepository<Thread>();
string sessionKey = "01234567890123456789012345678901234567890123456789";
User user = new User()
{
SessionKey = sessionKey
};
userFakeRepository.Add(user);
CategoryModel categoryModel = null;
CategoriesController categoriesController = new CategoriesController(
categoryFakeRepository, userFakeRepository, threadFakeRepository);
SetupController(categoriesController);
categoriesController.CreateCategory(categoryModel, sessionKey);
}
示例6: Get_GetByCategoryTest_OnlyOneThreadWithThatCategory_ShouldBeReturned
public void Get_GetByCategoryTest_OnlyOneThreadWithThatCategory_ShouldBeReturned()
{
FakeRepository<Thread> threadFakeRepository = new FakeRepository<Thread>();
FakeRepository<Category> categoryFakeRepository = new FakeRepository<Category>();
FakeRepository<User> userFakeRepository = new FakeRepository<User>();
string testCategory = "Test category";
User user = new User()
{
AuthCode = "0123456789012345678901234567890123456789",
Username = "TestUsername",
Nickname = "TestNickname",
SessionKey = "0SuGqVGqRwitYtijDvHlVfHGotklitbwHdYFkgwIRcIQjRASPQ"
};
Category category = new Category()
{
Name = testCategory
};
Thread thread = new Thread()
{
Title = "Test title",
Content = "Test content",
DateCreated = DateTime.Now,
Creator = user
};
thread.Categories.Add(category);
category.Threads.Add(thread);
user.Threads.Add(thread);
userFakeRepository.entities.Add(user);
threadFakeRepository.Add(thread);
categoryFakeRepository.Add(category);
ThreadsController threadsController = new ThreadsController(
categoryFakeRepository, threadFakeRepository, userFakeRepository);
SetupController(threadsController);
var threads = threadsController.GetByCategory(testCategory, user.SessionKey).ToList<ThreadModel>();
int expectedThreadCount = 1;
Assert.AreEqual(expectedThreadCount, threads.Count);
}
示例7: GetAllCategories_WhenASingleCategoryInRepository_ShouldReturnSingleCategory
public void GetAllCategories_WhenASingleCategoryInRepository_ShouldReturnSingleCategory()
{
var repository = new FakeRepository<Student>();
var studentToAdd = new Student()
{
FirstName = "Test category"
};
repository.Add(studentToAdd);
var controller = new StudentsController(repository);
var categoriesModels = controller.GetStudents();
Assert.IsTrue(categoriesModels.Count() == 1);
Assert.AreEqual(studentToAdd.FirstName, categoriesModels.First().FirstName);
}