public void InsertNewEventType_should_not_throw_exception_if_the_event_type_has_been_inserted_by_something_else()
        {
            Action changeAnotherUsersEmailInOtherAppDomain = () =>
            {
                AppDomainExtensions.ExecuteInCloneDomainScope(
                    () =>
                {
                    var test = new SqlServerEventStoreSessionTests();
                    test.Setup();
                    using (var session = test.OpenSession(test.CreateStore()))
                    {
                        var otherUser = User.Register(session, "*****@*****.**", "password", Guid.NewGuid());
                        otherUser.ChangeEmail("*****@*****.**");
                        session.SaveChanges();
                    }
                });
            };

            using (var session = OpenSession(CreateStore()))
            {
                var user = User.Register(session, "*****@*****.**", "password", Guid.NewGuid());
                session.SaveChanges();

                changeAnotherUsersEmailInOtherAppDomain();

                user.ChangeEmail("*****@*****.**");
                session.SaveChanges();
            }
        }
예제 #2
0
    public static Role GetRole(string key)
    {
        if (Roles.ContainsKey(key))
        {
            return(Roles[key]);
        }

        foreach (var appDomain in AppDomainExtensions.GetAllAppDomains())
        {
            foreach (var assembly in appDomain.GetAssemblies())
            {
                var type = assembly.GetTypes().Where(t => t.Name == key + "Role").FirstOrDefault();                        // (key + "Role", false, true);

                if (type == null || !typeof(Role).IsAssignableFrom(type))
                {
                    continue;
                }

                Role role = null;

                {
                    var fieldInfo = type.GetField("Instance", BindingFlags.Static | BindingFlags.Public);


                    if (fieldInfo != null)
                    {
                        role = fieldInfo.GetValue(null) as Role;
                    }
                    else
                    {
                        var propertyInfo = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public);

                        if (propertyInfo != null)
                        {
                            role = propertyInfo.GetValue(null, null) as Role;
                        }
                    }
                }

                if (role == null)
                {
                    continue;
                }

                Roles[key] = role;

                return(role);
            }
        }

        throw new KeyNotFoundException();
    }
예제 #3
0
        private string EnsureAbsolute(string path)
        {
            if (path.StartsWith("~"))
            {
                path = path.Substring(1);
            }

            if (path.StartsWith("/"))
            {
                path = Path.Combine(AppDomainExtensions.GetPrimaryAssemblyPath(), path.Substring(1));
            }

            return(path);
        }
        protected void Setup()
        {
            var binDirectory = AppDomainExtensions.GetPrimaryAssemblyPath();

            filePath = Path.Combine(binDirectory, "test.trig");
            if (!Directory.Exists(binDirectory))
            {
                Directory.CreateDirectory(binDirectory);
            }

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            FileStream fileStream = File.Create(filePath);

            GetType().GetTypeInfo().Assembly.GetManifestResourceStream("RomanticWeb.Tests.TestGraphs.TriplesWithLiteralSubjects.trig").CopyTo(fileStream);
            fileStream.Close();
        }