Exemplo n.º 1
0
        public void GeneratesContent()
        {
            var metaData    = new Dictionary <string, string>();
            var networkData = new NetworkData(new Dictionary <string, object>());
            var userData    = new List <UserData>
            {
                new(UserDataContentType.CloudConfig, "", Encoding.UTF8),
                new(UserDataContentType.CloudConfig, "", Encoding.UTF8)
            };

            var options = new GenerateConfigDriveOptions();

            var dsMock = new Mock <IConfigDriveDataSource>();

            dsMock.Setup(x => x.GenerateConfigDriveContent(It.IsAny <IDictionary <string, string> >(),
                                                           networkData,
                                                           It.Is <IEnumerable <UserData> >(x => x.SequenceEqual(userData)), options)).Verifiable();

            var configDrive = new Dbosoft.CloudInit.ConfigDrive.ConfigDrive(dsMock.Object);

            configDrive.AddMetaData(metaData);
            configDrive.SetNetworkData(networkData);

            foreach (var data in userData)
            {
                configDrive.AddUserData(data);
            }

            configDrive.GenerateContent(options);

            dsMock.Verify();
        }
Exemplo n.º 2
0
        public void ValidatesMetaData()
        {
            var metaData = new Dictionary <string, string>
            {
                { "a", "b" }
            };

            var dsMock = new Mock <IConfigDriveDataSource>();

            dsMock.Setup(x => x.ValidateMetaData(metaData)).Verifiable();

            var configDrive = new Dbosoft.CloudInit.ConfigDrive.ConfigDrive(dsMock.Object);

            configDrive.AddMetaData(metaData);

            dsMock.Verify();
        }