Exemple #1
0
        private void DeleteAssetOwner()
        {
            assetOwnerEvent.Action = Operation.Delete;
            _assetOwnerService.CheckExistingAssetOwner(Arg.Any <Guid>()).Returns(true);
            _assetServices.ValidateAuthorizedCustomerByAsset(Arg.Any <Guid>(), Arg.Any <Guid>()).Returns(false);
            _assetOwnerService.DeleteAssetOwnerEvent(Arg.Any <AssetOwnerEvent>()).Returns(true);
            var response = _controller.AssetOwner(assetOwnerEvent);

            Assert.Equal(200, ((Microsoft.AspNetCore.Mvc.StatusCodeResult)response).StatusCode);
        }
Exemple #2
0
        public void Create_Update_Delete_AssetOwnerEvent()
        {
            //Arrange for Create

            var assetOwnerEvent = new AssetOwnerEvent()
            {
                Action           = Operation.Create,
                ActionUTC        = DateTime.UtcNow,
                AssetUID         = new Guid(),
                AssetOwnerRecord = new VSS.MasterData.WebAPI.ClientModel.AssetOwner()
                {
                    AccountName         = "Sam",
                    AccountUID          = new Guid("a162eb79-0317-11e9-a988-029d68d36a0c"),
                    CustomerName        = "Cat",
                    CustomerUID         = new Guid("a162eb79-0317-11e9-a988-029d68d36a0d"),
                    DealerAccountCode   = "TD00",
                    DealerName          = "DemoDeler",
                    DealerUID           = new Guid("a162eb79-0317-11e9-a988-029d68d36a0e"),
                    NetworkCustomerCode = "SAP",
                    NetworkDealerCode   = "TeT",
                }
            };

            _transaction.Execute(Arg.Any <List <Action> >()).Returns(x =>
            {
                foreach (var action in x.Arg <List <Action> >())
                {
                    action();
                }
                return(true);
            });

            //Act
            Assert.True(_assetOwnerServices.CreateAssetOwnerEvent(assetOwnerEvent));

            //Arrange for Update
            assetOwnerEvent.Action = Operation.Update;

            //Act
            Assert.True(_assetOwnerServices.UpdateAssetOwnerEvent(assetOwnerEvent));

            //Arrange for Delete
            assetOwnerEvent.Action = Operation.Delete;

            //Act
            Assert.True(_assetOwnerServices.DeleteAssetOwnerEvent(assetOwnerEvent));
        }
Exemple #3
0
        private bool PerformAction(AssetOwnerEvent assetOwner, Operation operation)
        {
            bool result = false;

            switch (operation)
            {
            case Operation.Create:
                result = _assetOwnerRepository.CreateAssetOwnerEvent(assetOwner);
                break;

            case Operation.Update:
                result = Update(assetOwner);
                break;

            case Operation.Delete:
                result = _assetOwnerRepository.DeleteAssetOwnerEvent(assetOwner);
                break;
            }
            return(result);
        }