Example #1
0
        public void UpdateAssertTypeTest()
        {
            var note = $"{DateTime.Now}";

            var request   = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var assetType = new AssetType {
                Number                = "1030",
                Description           = "Patent",
                Notes                 = note,
                AccountAssetId        = 1030,
                AccountValueLossId    = 1039,
                AccountSaleLossId     = 7971,
                AccountSaleWinId      = 3971,
                AccountRevaluationId  = 2085,
                AccountWriteDownAckId = 1038,
                AccountWriteDownId    = 7710,
                AccountDepreciationId = 7813,
            };

            var updatedAssetType = AssetTypeService.UpdateAssetTypeAsync(request, 1, assetType).GetAwaiter().GetResult();

            Assert.AreEqual(1, updatedAssetType.Id);
            Assert.AreEqual("1030", updatedAssetType.Number);
            Assert.AreEqual("Patent", updatedAssetType.Description);
            Assert.AreEqual(note, updatedAssetType.Notes);
        }
Example #2
0
        public async Task GetAssetTypesTest()
        {
            var request  = new AssetTypeListRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var response = await AssetTypeService.GetAssetTypesAsync(request);

            Assert.IsTrue(response.Data.Count() > 0);
        }
Example #3
0
        public void GetAssetTypeTest()
        {
            var request  = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var response = AssetTypeService.GetAssetTypeAsync(request, 1).GetAwaiter().GetResult();

            Assert.IsTrue(response.Number == "1030");
            Assert.IsTrue(response.Description == "Patent");
        }
        public async void GetAssetTypes_List_ReturnsAssetTypesList()
        {
            using (var context = _factory.UseInMemory())
            {
                //Act
                var service = new AssetTypeService(context);
                var actual  = await service.GetAssetTypes();

                var expected = context.AssetTypes.Count();

                //Assert
                Assert.Equal(actual.Count(), expected);
            }
        }
Example #5
0
        // GET: Administrateur/AssetTypeSupportedMetaDatas/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var assetTypeSupportedMetaData = AssetTypeSupportedMetaDatasService.Get(id);

            if (assetTypeSupportedMetaData == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AssetTypeID = new SelectList(AssetTypeService.GetAssetTypes(), "AssetTypeID", "TypeLabel", assetTypeSupportedMetaData.AssetTypeID);
            ViewBag.MetaDataID  = new SelectList(MetaDataService.GetMetaDatas(), "MetaDataID", "Title", assetTypeSupportedMetaData.MetaDataID);
            return(View(assetTypeSupportedMetaData));
        }
Example #6
0
 public ActionResult Edit([Bind(Include = "AssetSupportedMetaDataID,AssetTypeID,MetaDataID")] AssetTypeSupportedMetaData assetTypeSupportedMetaData)
 {
     try
     {
         if (ModelState.IsValid)
         {
             AssetTypeSupportedMetaDatasService.Update(assetTypeSupportedMetaData);
             return(RedirectToAction("Index"));
         }
         ViewBag.AssetTypeID = new SelectList(AssetTypeService.GetAssetTypes(), "AssetTypeID", "TypeLabel", assetTypeSupportedMetaData.AssetTypeID);
         ViewBag.MetaDataID  = new SelectList(MetaDataService.GetMetaDatas(), "MetaDataID", "Title", assetTypeSupportedMetaData.MetaDataID);
         return(View(assetTypeSupportedMetaData));
     }
     catch (Exception ex)
     {
         return(View("Error", new HandleErrorInfo(ex, "AssetTypeSupportedMetaDatas", "Edit")));
     }
 }
        public async Task AddAssetType_ValidAssetType_ShouldAddNewAssetType()
        {
            using (var context = _factory.UseInMemory())
            {
                // Arrange
                var service = new AssetTypeService(context);

                // Act
                var actual = await service.AddAssetType(GetAssetType());

                var expected = GetAssetType();

                // Assert
                Assert.NotNull(actual);
                Assert.Equal(expected.Id, actual.Id);
                Assert.Equal(expected.Name, actual.Name);
            }
        }
        public async Task DeleteAssetType_ExistingAsset_ShouldDeleteAssetType()
        {
            using (var context = _factory.UseInMemory())
            {
                // Arrange
                var service = new AssetTypeService(context);
                context.Add(GetAssetType());
                context.SaveChanges();
                var assetType = context.AssetTypes.FirstOrDefault(x => x.Id == GetAssetType().Id);

                // Act
                await service.DeleteAssetType(assetType);

                var expected = context.AssetTypes.FirstOrDefault(x => x.Id == GetAssetType().Id);

                // Assert
                Assert.Null(expected);
            }
        }
Example #9
0
        public void CreateAndDeleteAssertTypeTest()
        {
            var request  = new FortnoxApiRequest(this.connectionSettings.AccessToken, this.connectionSettings.ClientSecret);
            var response = AssetTypeService.CreateAssetTypeAsync(request,
                                                                 new AssetType
            {
                Number                = "3346",
                Description           = "asset type description",
                Notes                 = "Some notes",
                Type                  = 1,
                AccountAssetId        = 1030,
                AccountDepreciationId = 7813,
                AccountValueLossId    = 1039
            }).GetAwaiter().GetResult();

            Assert.AreEqual("3346", response.Number);

            AssetTypeService.DeleteAssetTypeAsync(request, response.Id.Value).GetAwaiter().GetResult();
        }
        public async void GetAssetById_ExistingAsset_ReturnAsset()
        {
            using (var context = _factory.UseInMemory())
            {
                //Arrange
                var assetType = GetAssetType();
                context.Add(assetType);
                context.SaveChanges();

                //Act
                var service = new AssetTypeService(context);
                var actual  = await service.GetAssetType(assetType.Id);

                var expected = assetType;

                //Assert
                Assert.Equal(expected.Id, actual.Id);
                Assert.Equal(expected.Name, actual.Name);
            }
        }
Example #11
0
 // GET: Administrateur/AssetTypeSupportedMetaDatas/Create
 public ActionResult Create()
 {
     ViewBag.AssetTypeID = new SelectList(AssetTypeService.GetAssetTypes(), "AssetTypeID", "TypeLabel");
     ViewBag.MetaDataID  = new SelectList(MetaDataService.GetMetaDatas(), "MetaDataID", "Title");
     return(View());
 }