defmodule Outlook.PublicTest do
  use Outlook.DataCase

  # TODO: make this work

  alias Outlook.Public

  describe "artikel" do
    alias Outlook.Public.Artikel

    import Outlook.PublicFixtures

    @invalid_attrs %{date: nil, public_content: nil, teaser: nil, title: nil, translator: nil, unauthorized: nil}

    test "list_artikel/0 returns all artikel" do
      artikel = artikel_fixture()
      assert Artikel.list_artikel() == [artikel]
    end

    test "get_artikel!/1 returns the artikel with given id" do
      artikel = artikel_fixture()
      assert Artikel.get_artikel!(artikel.id) == artikel
    end

    test "create_artikel/1 with valid data creates a artikel" do
      valid_attrs = %{date: "some date", public_content: "some public_content", teaser: "some teaser", title: "some title", translator: "some translator", unauthorized: true}

      assert {:ok, %Artikel{} = artikel} = Artikel.create_artikel(valid_attrs)
      assert artikel.date == "some date"
      assert artikel.public_content == "some public_content"
      assert artikel.teaser == "some teaser"
      assert artikel.title == "some title"
      assert artikel.translator == "some translator"
      assert artikel.unauthorized == true
    end

    test "create_artikel/1 with invalid data returns error changeset" do
      assert {:error, %Ecto.Changeset{}} = Artikel.create_artikel(@invalid_attrs)
    end

    test "update_artikel/2 with valid data updates the artikel" do
      artikel = artikel_fixture()
      update_attrs = %{date: "some updated date", public_content: "some updated public_content", teaser: "some updated teaser", title: "some updated title", translator: "some updated translator", unauthorized: false}

      assert {:ok, %Artikel{} = artikel} = Artikel.update_artikel(artikel, update_attrs)
      assert artikel.date == "some updated date"
      assert artikel.public_content == "some updated public_content"
      assert artikel.teaser == "some updated teaser"
      assert artikel.title == "some updated title"
      assert artikel.translator == "some updated translator"
      assert artikel.unauthorized == false
    end

    test "update_artikel/2 with invalid data returns error changeset" do
      artikel = artikel_fixture()
      assert {:error, %Ecto.Changeset{}} = Artikel.update_artikel(artikel, @invalid_attrs)
      assert artikel == Artikel.get_artikel!(artikel.id)
    end

    test "delete_artikel/1 deletes the artikel" do
      artikel = artikel_fixture()
      assert {:ok, %Artikel{}} = Artikel.delete_artikel(artikel)
      assert_raise Ecto.NoResultsError, fn -> Artikel.get_artikel!(artikel.id) end
    end

    test "change_artikel/1 returns a artikel changeset" do
      artikel = artikel_fixture()
      assert %Ecto.Changeset{} = Artikel.change_artikel(artikel)
    end
  end

  describe "autoren" do
    alias Outlook.Public.Autor

    import Outlook.PublicFixtures

    @invalid_attrs %{description: nil, homepage_name: nil, homepage_url: nil, name: nil}

    test "list_autoren/0 returns all autoren" do
      autor = autor_fixture()
      assert Autoren.list_autoren() == [autor]
    end

    test "get_autor!/1 returns the autor with given id" do
      autor = autor_fixture()
      assert Autoren.get_autor!(autor.id) == autor
    end

    test "create_autor/1 with valid data creates a autor" do
      valid_attrs = %{description: "some description", homepage_name: "some homepage_name", homepage_url: "some homepage_url", name: "some name"}

      assert {:ok, %Autor{} = autor} = Autoren.create_autor(valid_attrs)
      assert autor.description == "some description"
      assert autor.homepage_name == "some homepage_name"
      assert autor.homepage_url == "some homepage_url"
      assert autor.name == "some name"
    end

    test "create_autor/1 with invalid data returns error changeset" do
      assert {:error, %Ecto.Changeset{}} = Autoren.create_autor(@invalid_attrs)
    end

    test "update_autor/2 with valid data updates the autor" do
      autor = autor_fixture()
      update_attrs = %{description: "some updated description", homepage_name: "some updated homepage_name", homepage_url: "some updated homepage_url", name: "some updated name"}

      assert {:ok, %Autor{} = autor} = Autoren.update_autor(autor, update_attrs)
      assert autor.description == "some updated description"
      assert autor.homepage_name == "some updated homepage_name"
      assert autor.homepage_url == "some updated homepage_url"
      assert autor.name == "some updated name"
    end

    test "update_autor/2 with invalid data returns error changeset" do
      autor = autor_fixture()
      assert {:error, %Ecto.Changeset{}} = Autoren.update_autor(autor, @invalid_attrs)
      assert autor == Autoren.get_autor!(autor.id)
    end

    test "delete_autor/1 deletes the autor" do
      autor = autor_fixture()
      assert {:ok, %Autor{}} = Autoren.delete_autor(autor)
      assert_raise Ecto.NoResultsError, fn -> Autoren.get_autor!(autor.id) end
    end

    test "change_autor/1 returns a autor changeset" do
      autor = autor_fixture()
      assert %Ecto.Changeset{} = Autoren.change_autor(autor)
    end
  end
end
