Пример #1
0
        public void GetSubscriptionForAsset_Null()
        {
            //Arrange
            _transaction.Get <OwnerVisibility>(Arg.Any <string>()).Returns(x => new List <OwnerVisibility>()
            {
                null
            });

            //Act
            var subscription = _supportAssetServices.GetSubscriptionForAsset(new Guid());

            //Assert
            Assert.Null(subscription.AssetUID);
        }
Пример #2
0
        public void GetAssetDetail()
        {
            _assetRepository.GetAssetDetail(Arg.Any <Guid>(), Arg.Any <Guid>()).Returns(x =>
                                                                                        new List <AssetDetail>()
            {
                new AssetDetail {
                    AssetCustomerUIDs = "a162eb79-0317-11e9-a988-029d68d36a0i", AssetName = "tesr", AssetTypeName = "sa", AssetUID = "a162eb79-0317-11e9-a988-029d68d36a0e", DeviceSerialNumber = "Awr", DeviceState = "Subscribed", DeviceType = "PL121", DeviceUID = "a162eb79-0317-11e9-a988-029d68d36a0d", MakeCode = "CAT", Model = "TT", ModelYear = 2019, OwningCustomerUID = "a162eb79-0317-11e9-a988-029d68d36a0c", SerialNumber = "qww", TimestampOfModification = DateTime.Now
                }
            });

            _supportAssetServices.GetAssetCustomerByAssetGuid(Arg.Any <Guid>()).Returns(x =>
                                                                                        new List <VSS.MasterData.WebAPI.ClientModel.AssetCustomer>()
            {
                new VSS.MasterData.WebAPI.ClientModel.AssetCustomer {
                    CustomerName = "AT", CustomerType = "Delear", CustomerUID = Guid.NewGuid(), ParentCustomerType = "Dealer", ParentCustomerUID = Guid.NewGuid(), ParentName = "CAT"
                }
            }
                                                                                        );

            _supportAssetServices.GetSubscriptionForAsset(Arg.Any <Guid>()).Returns(x =>
                                                                                    new AssetSubscriptionModel()
            {
                AssetUID = Guid.NewGuid(), SubscriptionStatus = "Subscribed", OwnersVisibility = new List <OwnerVisibility> {
                    new OwnerVisibility {
                        CustomerName = "AT", CustomerType = "Delear", CustomerUID = Guid.NewGuid(), SubscriptionName = "Dealer", SubscriptionUID = Guid.NewGuid(), SubscriptionStatus = "Active", SubscriptionEndDate = DateTime.Now, SubscriptionStartDate = DateTime.Now
                    }
                }
            }
                                                                                    );
            var response = _controller.GetAssetDetail(Guid.NewGuid(), Guid.NewGuid());

            Assert.Equal(200, ((Microsoft.AspNetCore.Mvc.ObjectResult)response).StatusCode);

            // Null Responce
            _assetRepository.GetAssetDetail(Arg.Any <Guid>(), Arg.Any <Guid>()).Returns(x => new List <AssetDetail>()
            {
            });
            response = _controller.GetAssetDetail(Guid.NewGuid(), Guid.NewGuid());
            Assert.Equal(200, ((Microsoft.AspNetCore.Mvc.ObjectResult)response).StatusCode);
            Assert.Empty(((List <AssetDeviceDetail>)((Microsoft.AspNetCore.Mvc.ObjectResult)response).Value));
        }
Пример #3
0
 private AssetSubscriptionModel GetSubscriptionfromAPI(Guid assetGUID)
 {
     try
     {
         var data = _supportAssetServices.GetSubscriptionForAsset(assetGUID);
         return(data);               //Newtonsoft.Json.JsonConvert.DeserializeObject<AssetSubscriptionModel>(data.ToString());
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(null);
     }
 }