public void WorkerController_Create_ReturnsObjectResult_withValidWorker() { controller = createContext(controller); Worker TestWorker = new Worker() { Id = 5, Username = "******", Password = "******",//1234 Email = "*****@*****.**", FirstName = "Bob7", LastName = "Bobsen6", Salt = "upYKQSsrlub5JAID61/6pA==" }; CreateUserModel <Worker> cm = new CreateUserModel <Worker>() { User = TestWorker, Password = TestWorker.Password }; var result = controller.Create(cm); var resultObjectResult = result as ObjectResult; var resultObject = resultObjectResult.Value as TaskHouseApi.Model.Worker; Assert.IsType <ObjectResult>(result); Assert.Equal(TestWorker.Id, resultObject.Id); }
public WorkersControllerUnitTest() { service = new Mock <IService <WorkerServiceModel> >(); mapper = new Mock <IMapper>(); log = new Mock <ILog>(); usersController = new WorkersController(service.Object, mapper.Object, log.Object); Arrange(); }
public Workers() { InitializeComponent(); c = (WorkersController)DataContext; c.Model.PropertyChanged += Model_AddWorker; c.Model.PropertyChanged += Model_DeleteWorker; c.Model.PropertyChanged += Model_EditWorker; }
void Awake() { tickController = GetComponent <TickController>(); selectionController = GetComponent <SelectionController>(); spawningMode = GetComponent <SpawningMode>(); workersController = GetComponent <WorkersController>(); shopBooster = GetComponent <ShopBooster>(); }
public async Task WorkersControllerTest() { var dbContext = await prepareDb(); var workersController = new WorkersController(dbContext); var workers = await workersController.Index(); Assert.NotNull(workers); }
public void PostRegistrated_WhenCalled_ReturnsInternalError() { // Arrange usersController = new WorkersController(null, null, log.Object); // Act var result = usersController.PostWorker(userController); // Assert var response = result as StatusCodeResult; Assert.Equal(500, response.StatusCode); }
public void DeleteRegistrated_WhenCalled__ReturnsInternalError(int id) { // Arrange usersController = new WorkersController(null, null, log.Object); // Act var result = usersController.DeleteWorker(id); Assert.IsType <StatusCodeResult>(result); // Assert var response = result as StatusCodeResult; Assert.Equal(500, response.StatusCode); }
private WorkersController createContext(WorkersController con) { con.ControllerContext = new ControllerContext(); //Creates a new HttpContext con.ControllerContext.HttpContext = new DefaultHttpContext(); con.ObjectValidator = new DefaultObjectValidator ( new DefaultModelMetadataProvider ( new DefaultCompositeMetadataDetailsProvider(Enumerable.Empty <IMetadataDetailsProvider>()) ), new List <Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IModelValidatorProvider>() ); //Returns the controller return(con); }
public WorkersControllerUnitTests() { unitOfWork = new FakeUnitOfWork(); controller = new WorkersController(unitOfWork, passwordService); }