public void GivenLastIdOnUsersList_WhenGetNewUserIdIsCalled_ShouldReturnCorrectNewUserId(int lastIdOnUsersList, int expectedNewUserId) { IdService getIdServ = new IdService(); var result = getIdServ.GetNewUserId(lastIdOnUsersList); result.ShouldBe(expectedNewUserId); }
public void FindDisbursementsByRetrievalIdTest() { //Arrange //get retrival object Retrieval retrieval = context.Retrieval.Where(x => x.RetrievalId == "TEST").First(); //save 2 disbursement objects Disbursement a = new Disbursement(); a.DisbursementId = IdService.GetNewDisbursementId(context); a.Retrieval = retrieval; a.CreatedDateTime = DateTime.Now; disbursementService.Save(a); Disbursement b = new Disbursement(); b.DisbursementId = IdService.GetNewDisbursementId(context); b.Retrieval = retrieval; b.CreatedDateTime = DateTime.Now; disbursementService.Save(b); //find any existing data in disbursement where RetrievalId = TESTER and add 2 more int expected = context.Disbursement.Where(x => x.Retrieval.RetrievalId == "TEST").Count(); //Act var result = disbursementService.FindDisbursementsByRetrievalId(retrieval.RetrievalId).Count; //Assert Assert.AreEqual(expected, result); //Delete dummy test objects in TestCleanUp }
public void AddNewItemCategoryTest() { //Arrange //Instantiate controller ItemCategoryController controller = new ItemCategoryController() { CurrentUserName = "******", context = this.context }; controller.ModelState.Clear(); //create new ViewModel to Save via controller ItemCategoryViewModel newItemCategory = new ItemCategoryViewModel() { ItemCategoryId = IdService.GetNewItemCategoryId(context), Name = "TEST" }; //Act ActionResult result = controller.Save(newItemCategory); //Assert Assert.IsNotNull(result); }
public void CreateDraftStockAdjustment(List <ViewModelFromNew> list) { userService = new UserService(Context); stockAdjustmentService = new StockAdjustmentService(Context); itemService = new ItemService(Context); notificationService = new NotificationService(Context); List <StockAdjustmentDetail> detaillist = new List <StockAdjustmentDetail>(); StockAdjustment s = new StockAdjustment(); s.StockAdjustmentId = IdService.GetNewStockAdjustmentId(Context); s.CreatedBy = userService.FindUserByEmail(CurrentUserName); s.CreatedDateTime = DateTime.Now; foreach (ViewModelFromNew v in list) { StockAdjustmentDetail sd = new StockAdjustmentDetail(); string itemcode = v.Itemcode; Item item = itemService.FindItemByItemCode(itemcode); sd.ItemCode = itemcode; sd.Reason = (v.Reason == null) ? "" : v.Reason; sd.StockAdjustmentId = s.StockAdjustmentId; sd.OriginalQuantity = item.Inventory.Quantity; sd.AfterQuantity = v.Adjustment + sd.OriginalQuantity; detaillist.Add(sd); // stockAdjustmentDetailRepository.Save(sd); } s.StockAdjustmentDetails = detaillist; stockAdjustmentService.CreateDraftStockAdjustment(s); }
public void LinkChildsToEntities(Contexts contexts, IView view, IdService idService) { view.Transform.GetComponentsInChildren(_emitterBuffer); foreach (var emitter in _emitterBuffer) { var e = emitter.Emit(); e.AddId(idService.GetNext()); e.AddChildOf(view.Id); var child = emitter.Transform; child.SetParent(_root); var childView = child.GetComponent <IView>(); if (childView != null) { childView.InitializeView(contexts, e); e.AddView(childView); } child.GetComponents(_eventListenerBuffer); foreach (var listener in _eventListenerBuffer) { listener.RegisterListeners(e); } } }
public LoginModel(RootModel root, MainModel main, UpdateModel updateModel, LocalSettingsService settingsService, ConnectionService connectionService, NotificationService notificationService, IAppEnvironment environment, IdService idService) { Root = root; _settingsService = settingsService; _connectionService = connectionService; _notificationService = notificationService; _main = main; _updateModel = updateModel; _environment = environment; _idService = idService; var s = settingsService.Settings; SavePassword = s.SavePassword; UserName = s.UserName; Password = s.Password; UserRegistered = s.UserRegistered; Version = ClientVersionHelper.GetVersion(); DoLogin = async() => await LoginAsync(true); DoAnonymousLogin = async() => await LoginAsync(false); if (s.AutoLogon && s.SavePassword && s.UserRegistered) { _ = DoAutoLogin(); } }
public MainAboutModel(RootModel root, ConnectionService connectionService, IAppEnvironment environment, IdService idService, CoreData coreData) { Root = root; _connectionService = connectionService; _environment = environment; _idService = idService; _coreData = coreData; CopyToClipboard = () => DoCopyToClipboard(); Version = ClientVersionHelper.GetVersion(); var assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream("Streamster.ClientCore.LICENSE.txt")) using (StreamReader reader = new StreamReader(stream)) { License = reader.ReadToEnd(); } using (Stream stream = assembly.GetManifestResourceStream("Streamster.ClientCore.CREDITS.txt")) using (StreamReader reader = new StreamReader(stream)) { Credits = reader.ReadToEnd(); } FeedbackSend = () => _ = SendFeedback(); }
public void ReadNotification_Read_Redirect() { // Arrange var controller = new NotificationController() { Context = context }; var notificationId = IdService.GetNewNotificationId(context); notificationService.Save(new Notification() { NotificationId = notificationId, NotificationType = new NotificationTypeRepository(context).FindById(1), Contents = "DSB-201801-001", Status = new StatusService(context).FindStatusByStatusId(15), CreatedDateTime = DateTime.Now }); // Act var result = controller.Read(notificationId); // Assert Assert.AreEqual(15, notificationService.FindNotificationById(notificationId).Status.StatusId); result.AssertActionRedirect().ToAction("DisbursementDetails"); }
public async Task <IHttpActionResult> PutDay(int id, [FromBody] Day day) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //if requested day is not in a class the user owns if (!IdService.isValidDayId(id, db, User)) { return(BadRequest("invalid day id for the given user")); } db.Entry(day).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DayExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.OK)); }
public void GetNewStockAdjustmentId_ExistingId_Valid() { // Arrange string expectedPrefix = $"ADJ-{DateTime.Now.Year}{DateTime.Now.Month:00}"; var previous = IdService.GetNewStockAdjustmentId(context); new StockAdjustmentRepository(context).Save(new StockAdjustment() { StockAdjustmentId = previous, Remarks = "IDSERVICETEST", CreatedDateTime = DateTime.Now.AddDays(1 - DateTime.Today.Day), }); // Act var current = IdService.GetNewStockAdjustmentId(context); new StockAdjustmentRepository(context).Save(new StockAdjustment() { StockAdjustmentId = current, Remarks = "IDSERVICETEST", CreatedDateTime = DateTime.Now, }); var previousSerialNoParseResult = Int32.TryParse(previous.Substring(previous.Length - 3), out int previousSerialNo); var resultSerialNoParseResult = Int32.TryParse(current.Substring(current.Length - 3), out int resultSerialNo); // Assert Assert.AreEqual(1, resultSerialNo - previousSerialNo); }
public void GetNewDeliveryOrderNo_ExistingId_Valid() { // Arrange string expectedPrefix = $"DO-{DateTime.Now.Year}{DateTime.Now.Month:00}"; var previous = IdService.GetNewDeliveryOrderNo(context); new DeliveryOrderRepository(context).Save(new DeliveryOrder() { DeliveryOrderNo = previous, InvoiceFileName = "IDSERVICETEST", CreatedDateTime = DateTime.Now.AddDays(1 - DateTime.Today.Day), }); // Act var current = IdService.GetNewDeliveryOrderNo(context); new DeliveryOrderRepository(context).Save(new DeliveryOrder() { DeliveryOrderNo = current, InvoiceFileName = "IDSERVICETEST", CreatedDateTime = DateTime.Now, }); var previousSerialNoParseResult = Int32.TryParse(previous.Substring(previous.Length - 3), out int previousSerialNo); var resultSerialNoParseResult = Int32.TryParse(current.Substring(current.Length - 3), out int resultSerialNo); // Assert Assert.AreEqual(1, resultSerialNo - previousSerialNo); }
public void GetNewRetrievalId_ExistingId_Valid() { // Arrange string expectedPrefix = $"RET-{DateTime.Now.Year}{DateTime.Now.Month:00}"; var previous = IdService.GetNewRetrievalId(context); new RetrievalRepository(context).Save(new Retrieval() { RetrievalId = previous, Status = new StatusService(context).FindStatusByStatusId(16), CreatedDateTime = DateTime.Now.AddDays(1 - DateTime.Today.Day), }); // Act var current = IdService.GetNewRetrievalId(context); new RetrievalRepository(context).Save(new Retrieval() { RetrievalId = current, Status = new StatusService(context).FindStatusByStatusId(16), CreatedDateTime = DateTime.Now, }); var previousSerialNoParseResult = Int32.TryParse(previous.Substring(previous.Length - 3), out int previousSerialNo); var resultSerialNoParseResult = Int32.TryParse(current.Substring(current.Length - 3), out int resultSerialNo); // Assert Assert.AreEqual(1, resultSerialNo - previousSerialNo); }
public void GetNewStockMovementIdTest() { // Act var result = IdService.GetNewStockMovementId(context); // Assert Assert.IsNotNull(result); }
public void GetNewDelegationIdTest() { // Act var result = IdService.GetNewDelegationId(context); // Assert Assert.IsNotNull(result); }
// GET: api/Students //working as intended public IQueryable <Student> GetStudents() { var User_Id = IdService.getUserId(db, User); var result = db.Students.Where((s) => s.User_Id == User_Id); return(result); }
public CoreData(IdService environment, IDeltaServiceProvider deltaServiceProvider, HubConnectionService hubConnectionService) { _idService = environment; _hubConnectionService = hubConnectionService; _manager = Build(deltaServiceProvider); _manager.RootChanged += OnRootChanged; _syncContext = SynchronizationContext.Current; }
public void TestCleanup() { var usedNotificationId = IdService.GetNewNotificationId(context) - 1; if (notificationRepository.ExistsById(usedNotificationId)) { notificationRepository.Delete(notificationRepository.FindById(usedNotificationId)); } }
private void CreateReserveSlot(Vector2 pos) { var reserveSlot = _contexts.game.CreateEntity(); reserveSlot.isReserveSlot = true; reserveSlot.AddPosition(pos); reserveSlot.AddId(IdService.GetNewId()); PieceCreationService.CreateReservePiece(reserveSlot); }
// GET: api/Classrooms //working as intended public IQueryable <Classroom> GetClassrooms() { var User_Id = IdService.getUserId(db, User); var result = from c in db.Classrooms where c.User_Id == User_Id select c; return(result); }
public void GetNewCollectionPointIdTest() { // Arrange int expected = context.CollectionPoint.OrderByDescending(x => x.CollectionPointId).FirstOrDefault().CollectionPointId + 1; // Act var result = IdService.GetNewCollectionPointId(context); // Assert Assert.AreEqual(expected, result); }
public void GetNewItemCategoryIdTest() { // Arrange int expected = context.ItemCategory.OrderByDescending(x => x.ItemCategoryId) .FirstOrDefault().ItemCategoryId + 1; // Act var result = IdService.GetNewItemCategoryId(context); // Assert Assert.AreEqual(expected, result); }
public void GetNewDisbursementIdTest() { // Arrange string expectedPrefix = $"DSB-{DateTime.Now.Year}{DateTime.Now.Month:00}"; // Act var result = IdService.GetNewDisbursementId(context); var serialNoParseResult = Int32.TryParse(result.Substring(result.Length - 3), out int serialNo); // Assert Assert.AreEqual(expectedPrefix, result.Substring(0, 10)); Assert.IsTrue(serialNoParseResult); }
public async Task <IHttpActionResult> GetClassroom(int id) { var User_Id = IdService.getUserId(db, User); Classroom classroom = await db.Classrooms.Where((c) => c.User_Id == User_Id && c.Cls_Id == id).FirstOrDefaultAsync(); if (classroom == null) { return(NotFound()); } return(Ok(classroom)); }
public async Task <IHttpActionResult> GetStudent(int id) { var User_Id = IdService.getUserId(db, User); Student student = await db.Students.Where((s) => s.User_Id == User_Id && s.Stu_Id == id).FirstOrDefaultAsync(); if (student == null) { return(NotFound()); } return(Ok(student)); }
public async Task <IHttpActionResult> PostClassroom(Classroom classroom) { classroom.User_Id = IdService.getUserId(db, User); //sets the user id for the new classroom if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Classrooms.Add(classroom); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = classroom.Cls_Id }, classroom)); }
public LiveHub(IDbService dBService, IdService idService, LanguageService languageService, CourseService courseService, UserService userService, NotificationFlag notificationFlag, SubmitSolutionService submitSolutionService, ILogger <LiveHub> logger) { _dbService = dBService; _idService = idService; _languageService = languageService; _courseService = courseService; _userService = userService; _logger = logger; _notificationFlag = notificationFlag; _submitSolutionService = submitSolutionService; }
public async Task <IHttpActionResult> PostStudent(Student student) { student.User_Id = IdService.getUserId(db, User); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Students.Add(student); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = student.Stu_Id }, student)); }
public void ReadNotification_AlreadyRead() { // Arrange var notificationId = IdService.GetNewNotificationId(context); notificationService.Save(new Notification() { NotificationId = notificationId, Status = new StatusService(context).FindStatusByStatusId(15), CreatedDateTime = DateTime.Now }); // Act var result = notificationService.ReadNotification(notificationId); }
public void TestInitialize() { context = new ApplicationDbContext(); itemRepository = new ItemRepository(context); itemcategoryService = new ItemCategoryService(context); itemcategoryRepository = new ItemCategoryRepository(context); //create new ItemCategory object and save into DB ItemCategory ic = itemcategoryRepository.Save(new ItemCategory() { ItemCategoryId = IdService.GetNewItemCategoryId(context), Name = "TEST", CreatedDateTime = DateTime.Now }); }
public void SaveTest() { //Arrange Disbursement newDisbursement = new Disbursement(); newDisbursement.DisbursementId = IdService.GetNewDisbursementId(context); newDisbursement.CreatedDateTime = DateTime.Now; string expected = newDisbursement.DisbursementId; //Act var result = disbursementService.Save(newDisbursement); disbursementRepository.Delete(newDisbursement); //Assert Assert.AreEqual(expected, result.DisbursementId); }