public void AssetComparer_AssetOwnerChangedOnNewData_HolderUpdated()
        {
            // Arrange
            AssetHolder assetHolder1 = new AssetHolder();
            AssetHolder assetHolder2 = new AssetHolder();

            List <IAsset> currentAssets = new List <IAsset> {
                new Computer()
                {
                    PcName = "PC1"
                }
            };
            List <IAsset> assetsFromCsvList = new List <IAsset> {
                new Computer()
                {
                    PcName = "PC1"
                }
            };

            assetsFromCsvList[0].Transfer.ToUser(assetHolder2);
            currentAssets[0].Transfer.ToUser(assetHolder1);

            AssetComparer <IAsset> assetComparer = new AssetComparer <IAsset>(currentAssets);

            // Act
            assetComparer.OnNewData(assetsFromCsvList);

            // Assert
            Assert.That(currentAssets[0].LastAssetRecord.Holder, Is.EqualTo(assetHolder2));
        }
        public void OnNewData_AssetMissingInList_AssetStateIsMissing()
        {
            // Arrange
            List <Computer> currentAssets = new List <Computer> {
                Asset1, Asset2
            };
            List <Computer> assetsFromList = new List <Computer> {
                Asset1
            };

            AssetComparer <Computer> assetComparer = new AssetComparer <Computer>(currentAssets);

            // Act
            assetComparer.OnNewData(assetsFromList);

            // Assert
            Assert.AreEqual(Asset2.CurrentState, AssetState.Missing);
        }
        public void OnNewData_AssetReappearsInList_AssetStateIsOnline()
        {
            // Arrange
            Asset1.ChangeState.ToOnline();
            Asset2.ChangeState.ToMissing();

            List <Computer> currentAssets = new List <Computer> {
                Asset1, Asset2
            };
            List <Computer> assetsFromList = new List <Computer> {
                Asset1, Asset2
            };

            AssetComparer <Computer> assetComparer = new AssetComparer <Computer>(currentAssets);

            // Act
            assetComparer.OnNewData(assetsFromList);

            // Assert
            Assert.AreEqual(Asset2.CurrentState, AssetState.Online);
        }
        public void OnNewData_NewAssetsFound_NewAssetAdded()
        {
            // Arrange
            List <IAsset> currentAssets = new List <IAsset> {
                Asset1
            };
            List <IAsset> assetsFromList = new List <IAsset> {
                Asset1, Asset2
            };

            AssetComparer <IAsset> assetComparer = new AssetComparer <IAsset>(currentAssets);

            int numNewAssets = 0;

            assetComparer.NewAssetsFound += (newAssets) => { numNewAssets = newAssets.Count; };

            // Act
            assetComparer.OnNewData(assetsFromList);

            // Assert
            Assert.That(numNewAssets, Is.EqualTo(1));
        }