Exemple #1
0
        public async Task TestAddingClass_Defaults()
        {
            DataItemClass c = new DataItemClass()
            {
                Identifier      = Guid.NewGuid(),
                UpperIdentifier = base.CurrentSemesterId,
                Credits         = 3,
                Name            = "Math",
                Details         = "",
                RawColor        = ColorTools.GetArray(Colors.Red, 3)
            };

            DataChanges changes = new DataChanges();

            changes.Add(c);

            await base.DataStore.ProcessLocalChanges(changes);

            var viewModel = await ViewModelClass.LoadAsync(base.LocalAccountId, c.Identifier, DateTime.Today);

            var viewClass = viewModel.Class;

            Assert.AreEqual("Math", viewClass.Name);
            Assert.AreEqual(3, viewClass.Credits);
            Assert.AreEqual("", viewClass.Details);
            Assert.AreEqual(Colors.Red, viewClass.Color);
        }
        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            if (value is Color)
            {
                return(ColorTools.GetArray((Color)value, 3));
            }

            return(value);
        }
        protected override async Task InitializeAfterSemesters()
        {
            DataChanges changes = new DataChanges();

            changes.Add(new DataItemClass()
            {
                Credits         = 3,
                Details         = "Some details about Math class",
                Identifier      = Guid.NewGuid(),
                Name            = "Math",
                RawColor        = ColorTools.GetArray(Colors.Blue, 3),
                UpperIdentifier = CurrentSemesterId
            });

            CurrentClassId = Guid.NewGuid();

            changes.Add(new DataItemClass()
            {
                Name            = "English",
                Details         = "The class where you write essays in.",
                Identifier      = CurrentClassId,
                Credits         = 4,
                RawColor        = ColorTools.GetArray(Colors.Red, 3),
                UpperIdentifier = CurrentSemesterId
            });

            changes.Add(new DataItemClass()
            {
                Name            = "Spanish",
                Details         = "Learn a foreign language",
                Identifier      = Guid.NewGuid(),
                Credits         = 4,
                RawColor        = ColorTools.GetArray(Colors.Green, 3),
                UpperIdentifier = base.CurrentSemesterId
            });

            changes.Add(new DataItemClass()
            {
                Name            = "Science",
                Details         = "Perform experiments",
                Identifier      = Guid.NewGuid(),
                Credits         = 4,
                RawColor        = ColorTools.GetArray(Colors.Purple, 3),
                UpperIdentifier = base.CurrentSemesterId
            });

            await DataStore.ProcessLocalChanges(changes);
        }