Example #1
0
        public void ActionsByInventarizationsWorks()
        {
//            DELETE FROM public."Tasks";
//DELETE FROM public."Users";
//DELETE FROM public."Actions";
//DELETE FROM public."Zones";
//DELETE FROM public."Inventorizations";
//DELETE FROM public."Companies"

            User user = userRepositoriy.CreateUser(new User()
            {
                FirstName = "test_name", FamilyName = "test_family", MiddleName = "test_middlename", Level = UserLevel.Scaner, CreatedAt = DateTime.UtcNow, Login = "******", Password = "******"
            });
            Company company = companyRepositoriy.CreateCompany("Тест1");

            Business.Model.Inventorization inventarisation = inventorizationRepositoriy.CreateInventorization(company.Id, DateTime.UtcNow);
            Guid firstActionId  = Guid.NewGuid();
            Guid secondActionId = Guid.NewGuid();

            Business.Model.Action firstAction = new Business.Model.Action()
            {
                Id              = firstActionId,
                DateTime        = DateTime.UtcNow,
                Type            = ActionType.FirstScan,
                UserId          = user.Id,
                Inventorization = inventarisation.Id,
                BarCode         = "1",
                Quantity        = 1,
            };

            Business.Model.Action secondAction = new Business.Model.Action()
            {
                Id       = firstActionId,
                DateTime = DateTime.UtcNow,
                Type     = ActionType.FirstScan,
                UserId   = user.Id,
                Zone     = inventarisation.Id,
                BarCode  = "1",
                Quantity = 1,
            };

            actionRepository.CreateAction(firstAction);
            actionRepository.CreateAction(secondAction);
            List <Business.Model.Action> actions = actionRepository.GetActionsByInventorization(inventarisation.Id);

            Assert.IsNotNull(actions);
            Assert.AreEqual(2, actions.Count());

            actionRepository.DeleteAction(firstActionId);
            actionRepository.DeleteAction(secondActionId);
            inventorizationRepositoriy.DeleteInventorization(inventarisation.Id);
            companyRepositoriy.DeleteCompany(company.Id);
            userRepositoriy.DeleteUser(user.Id);
        }