Esempio n. 1
0
        public static void AtomicEnumTest()
        {
            var value = new AtomicEnum <EnvironmentVariableTarget>();

            Equal(EnvironmentVariableTarget.Process, value.Value);
            Equal(EnvironmentVariableTarget.Process, value.GetAndSet(EnvironmentVariableTarget.Machine));
            Equal(EnvironmentVariableTarget.Machine, value.Value);
            Equal(EnvironmentVariableTarget.Machine, value.GetAndUpdate(x => EnvironmentVariableTarget.User));
            Equal(EnvironmentVariableTarget.User, value.Value);
        }
        public static void AtomicEnumTest()
        {
            var value = new AtomicEnum <EnvironmentVariableTarget>();

            True(value.Equals(EnvironmentVariableTarget.Process));
            False(value.Equals(EnvironmentVariableTarget.User));
            Equal(EnvironmentVariableTarget.Process, value.Value);
            Equal(EnvironmentVariableTarget.Process, value.GetAndSet(EnvironmentVariableTarget.Machine));
            Equal(EnvironmentVariableTarget.Machine, value.Value);
            Equal(EnvironmentVariableTarget.Machine, value.GetAndUpdate(x => EnvironmentVariableTarget.User));
            Equal(EnvironmentVariableTarget.User, value.Value);
            Equal(EnvironmentVariableTarget.User.ToString(), value.ToString());
            value.Value = EnvironmentVariableTarget.Process;
            Equal(EnvironmentVariableTarget.Machine, value.SetAndGet(EnvironmentVariableTarget.Machine));
            Equal(EnvironmentVariableTarget.Machine, value.Value);
            Equal(EnvironmentVariableTarget.User, value.UpdateAndGet(x =>
            {
                Equal(EnvironmentVariableTarget.Machine, x);
                return(EnvironmentVariableTarget.User);
            }));
            value.Value = EnvironmentVariableTarget.Process;
            Equal(EnvironmentVariableTarget.Process, value.GetAndAccumulate(EnvironmentVariableTarget.User, (current, update) =>
            {
                Equal(EnvironmentVariableTarget.Process, current);
                Equal(EnvironmentVariableTarget.User, update);
                return((int)current + update);
            }));
            Equal(EnvironmentVariableTarget.User, value.Value);
            value.Value = EnvironmentVariableTarget.Process;
            Equal(EnvironmentVariableTarget.User, value.AccumulateAndGet(EnvironmentVariableTarget.User, (current, update) =>
            {
                Equal(EnvironmentVariableTarget.Process, current);
                Equal(EnvironmentVariableTarget.User, update);
                return((int)current + update);
            }));
            Equal(EnvironmentVariableTarget.User, value.Value);
        }